! function(e, t) { for (var n in t) e[n] = t[n] }(window, function(e) {
    var t = {};

    function n(r) { if (t[r]) return t[r].exports; var i = t[r] = { i: r, l: !1, exports: {} }; return e[r].call(i.exports, i, i.exports, n), i.l = !0, i.exports }
    return n.m = e, n.c = t, n.d = function(e, t, r) { n.o(e, t) || Object.defineProperty(e, t, { enumerable: !0, get: r }) }, n.r = function(e) { "undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(e, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(e, "__esModule", { value: !0 }) }, n.t = function(e, t) {
        if (1 & t && (e = n(e)), 8 & t) return e;
        if (4 & t && "object" == typeof e && e && e.__esModule) return e;
        var r = Object.create(null);
        if (n.r(r), Object.defineProperty(r, "default", { enumerable: !0, value: e }), 2 & t && "string" != typeof e)
            for (var i in e) n.d(r, i, function(t) { return e[t] }.bind(null, i));
        return r
    }, n.n = function(e) { var t = e && e.__esModule ? function() { return e.default } : function() { return e }; return n.d(t, "a", t), t }, n.o = function(e, t) { return Object.prototype.hasOwnProperty.call(e, t) }, n.p = "", n(n.s = 74)
}([function(e, t, n) {
    "use strict";
    n.d(t, "c", function() { return i }), n.d(t, "a", function() { return o }), n.d(t, "b", function() { return a }), n.d(t, "d", function() { return s }), n.d(t, "g", function() { return u }), n.d(t, "e", function() { return c }), n.d(t, "f", function() { return f });
    /*! *****************************************************************************
    Copyright (c) Microsoft Corporation.

    Permission to use, copy, modify, and/or distribute this software for any
    purpose with or without fee is hereby granted.

    THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
    REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
    AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
    INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
    LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
    OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
    PERFORMANCE OF THIS SOFTWARE.
    ***************************************************************************** */
    var r = function(e, t) {
        return (r = Object.setPrototypeOf || { __proto__: [] }
            instanceof Array && function(e, t) { e.__proto__ = t } || function(e, t) { for (var n in t) t.hasOwnProperty(n) && (e[n] = t[n]) })(e, t)
    };

    function i(e, t) {
        function n() { Object.defineProperty(this, "constructor", { value: e }) }
        r(e, t), e.prototype = null === t ? Object.create(t) : (n.prototype = t.prototype, new n)
    }
    var o = function() {
        return (o = Object.assign || function(e) {
            for (var t, n = 1, r = arguments.length; n < r; n++)
                for (var i in t = arguments[n]) Object.prototype.hasOwnProperty.call(t, i) && (e[i] = t[i]);
            return e
        }).apply(this, arguments)
    };

    function a(e, t, n, r) {
        return new(n || (n = Promise))(function(i, o) {
            function a(e) { try { u(r.next(e)) } catch (e) { o(e) } }

            function s(e) { try { u(r.throw(e)) } catch (e) { o(e) } }

            function u(e) { e.done ? i(e.value) : function(e) { return e instanceof n ? e : new n(function(t) { t(e) }) }(e.value).then(a, s) }
            u((r = r.apply(e, t || [])).next())
        })
    }

    function s(e, t) {
        var n, r, i, o, a = { label: 0, sent: function() { if (1 & i[0]) throw i[1]; return i[1] }, trys: [], ops: [] };
        return o = { next: s(0), throw: s(1), return: s(2) }, "function" == typeof Symbol && (o[Symbol.iterator] = function() { return this }), o;

        function s(o) {
            return function(s) {
                return function(o) {
                    if (n) throw new TypeError("Generator is already executing.");
                    for (; a;) try {
                        if (n = 1, r && (i = 2 & o[0] ? r.return : o[0] ? r.throw || ((i = r.return) && i.call(r), 0) : r.next) && !(i = i.call(r, o[1])).done) return i;
                        switch (r = 0, i && (o = [2 & o[0], i.value]), o[0]) {
                            case 0:
                            case 1:
                                i = o;
                                break;
                            case 4:
                                return a.label++, { value: o[1], done: !1 };
                            case 5:
                                a.label++, r = o[1], o = [0];
                                continue;
                            case 7:
                                o = a.ops.pop(), a.trys.pop();
                                continue;
                            default:
                                if (!(i = (i = a.trys).length > 0 && i[i.length - 1]) && (6 === o[0] || 2 === o[0])) { a = 0; continue }
                                if (3 === o[0] && (!i || o[1] > i[0] && o[1] < i[3])) { a.label = o[1]; break }
                                if (6 === o[0] && a.label < i[1]) { a.label = i[1], i = o; break }
                                if (i && a.label < i[2]) { a.label = i[2], a.ops.push(o); break }
                                i[2] && a.ops.pop(), a.trys.pop();
                                continue
                        }
                        o = t.call(e, a)
                    } catch (e) { o = [6, e], r = 0 } finally { n = i = 0 }
                    if (5 & o[0]) throw o[1];
                    return { value: o[0] ? o[1] : void 0, done: !0 }
                }([o, s])
            }
        }
    }

    function u(e) {
        var t = "function" == typeof Symbol && Symbol.iterator,
            n = t && e[t],
            r = 0;
        if (n) return n.call(e);
        if (e && "number" == typeof e.length) return { next: function() { return e && r >= e.length && (e = void 0), { value: e && e[r++], done: !e } } };
        throw new TypeError(t ? "Object is not iterable." : "Symbol.iterator is not defined.")
    }

    function c(e, t) {
        var n = "function" == typeof Symbol && e[Symbol.iterator];
        if (!n) return e;
        var r, i, o = n.call(e),
            a = [];
        try {
            for (;
                (void 0 === t || t-- > 0) && !(r = o.next()).done;) a.push(r.value)
        } catch (e) { i = { error: e } } finally { try { r && !r.done && (n = o.return) && n.call(o) } finally { if (i) throw i.error } }
        return a
    }

    function f() { for (var e = [], t = 0; t < arguments.length; t++) e = e.concat(c(arguments[t])); return e }
}, function(e, t, n) {
    "use strict";
    n.d(t, "b", function() { return s }), n.d(t, "e", function() { return u }), n.d(t, "g", function() { return c }), n.d(t, "c", function() { return f }), n.d(t, "f", function() { return l }), n.d(t, "a", function() { return d }), n.d(t, "d", function() { return h });
    var r = n(0),
        i = n(2),
        o = n(10),
        a = n(3),
        s = function(e) {
            function t(t) { var n = e.call(this, t.errMsg) || this; return n.errCode = -1, Object.defineProperties(n, { message: { get: function() { return "errCode: " + this.errCode + " " + (a.a[this.errCode] || "") + " | errMsg: " + this.errMsg }, set: function(e) { this.errMsg = e } } }), n.errCode = t.errCode || -1, n.errMsg = t.errMsg, n }
            return Object(r.c)(t, e), Object.defineProperty(t.prototype, "message", { get: function() { return "errCode: " + this.errCode + " | errMsg: " + this.errMsg }, set: function(e) { this.errMsg = e }, enumerable: !1, configurable: !0 }), t
        }(Error);

    function u(e) { return e && e instanceof Error && Object(i.k)(e.errMsg) }

    function c(e, t) {
        if (e && u(e)) return e;
        var n = function(e, t) {
            if (void 0 === t && (t = ""), e) {
                if (u(e)) return t && (e.errMsg += "; " + t), e;
                var n = e ? e.errCode : void 0,
                    r = (e && e.errMsg || e.toString() || "unknown error") + "; " + t;
                return new s({ errCode: n, errMsg: r })
            }
            return new s({ errMsg: t })
        }(e, "at " + t + " api; ");
        return n.errMsg = Object(o.a)(t, n.errMsg), n
    }
    var f = function(e) {
            function t(t, n) { var r = e.call(this, t) || this; return r.type = "timeout", r.generic = !0, r.payload = n, r }
            return Object(r.c)(t, e), t
        }(Error),
        l = function(e) { return "timeout" === e.type },
        d = function(e) {
            function t(t, n) { var r = e.call(this, t) || this; return r.type = "cancelled", r.generic = !0, r.payload = n, r }
            return Object(r.c)(t, e), t
        }(Error),
        h = function(e) { return "cancelled" === e.type }
}, function(e, t, n) {
    "use strict";
    n.d(t, "a", function() { return r }), n.d(t, "g", function() { return i }), n.d(t, "k", function() { return o }), n.d(t, "f", function() { return a }), n.d(t, "i", function() { return s }), n.d(t, "d", function() { return u }), n.d(t, "b", function() { return c }), n.d(t, "c", function() { return f }), n.d(t, "j", function() { return l }), n.d(t, "e", function() { return d }), n.d(t, "h", function() { return h });
    var r = function(e) { return Object.prototype.toString.call(e).slice(8, -1).toLowerCase() },
        i = function(e) { return "object" === r(e) },
        o = function(e) { return "string" === r(e) },
        a = function(e) { return "number" === r(e) },
        s = function(e) { return "promise" === r(e) },
        u = function(e) { return "function" == typeof e },
        c = function(e) { return Array.isArray(e) },
        f = function(e) { return "date" === r(e) },
        l = function(e) { return "regexp" === r(e) },
        d = function(e) { return e && "symbol" === r(e._internalType) },
        h = function(e) { if ("object" != typeof e || null === e) return !1; for (var t = e; null !== Object.getPrototypeOf(t);) t = Object.getPrototypeOf(t); return Object.getPrototypeOf(e) === t }
}, function(e, t, n) {
    "use strict";
    n.d(t, "a", function() { return r });
    var r = { "-1": "", UNKNOWN_ERROR: -1, "-401001": "api permission denied", SDK_API_PERMISSION_DENIED: -401001, "-401002": "api parameter error", SDK_API_PARAMETER_ERROR: -401002, "-401003": "api parameter type error", SDK_API_PARAMETER_TYPE_ERROR: -401003, "-402001": "circular reference detected", SDK_DATABASE_CIRCULAR_REFERENCE: -402001, "-402002": "realtime listener init watch fail", SDK_DATABASE_REALTIME_LISTENER_INIT_WATCH_FAIL: -402002, "-402003": "realtime listener reconnect ws fail", SDK_DATABASE_REALTIME_LISTENER_RECONNECT_WS_FAIL: -402003, "-402004": "realtime listener rebuild watch fail", SDK_DATABASE_REALTIME_LISTENER_REBUILD_WATCH_FAIL: -402004, "-402005": "realtime listener close watch fail", SDK_DATABASE_REALTIME_LISTENER_CLOSE_WATCH_FAIL: -402005, "-402006": "realtime listener receive server error msg", SDK_DATABASE_REALTIME_LISTENER_SERVER_ERROR_MSG: -402006, "-402007": "realtime listener receive invalid server data", SDK_DATABASE_REALTIME_LISTENER_RECEIVE_INVALID_SERVER_DATA: -402007, "-402008": "realtime listener websocket connection error", SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_ERROR: -402008, "-402009": "realtime listener websocket connection closed", SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_CLOSED: -402009, "-402010": "realtime listener check last fail", SDK_DATABASE_REALTIME_LISTENER_CHECK_LAST_FAIL: -402010, "-402011": "realtime listener unexpected fatal error", SDK_DATABASE_REALTIME_LISTENER_UNEXPECTED_FATAL_ERROR: -402011, "-402012": "realtime listener init ws fail", SDK_DATABASE_REALTIME_LISTENER_INIT_WS_FAIL: -402012, "-403001": "max upload file size exceeded", SDK_STORAGE_EXCEED_MAX_UPLOAD_SIZE: -403001, "-403002": "internal server error: empty upload url", SDK_STORAGE_INTERNAL_SERVER_ERROR_EMPTY_UPLOAD_URL: -403002, "-403003": "internal server error: empty download url", SDK_STORAGE_INTERNAL_SERVER_ERROR_EMPTY_DOWNLOAD_URL: -403003, "-404001": "empty call result", SDK_FUNCTIONS_EMPTY_CALL_RESULT: -404001, "-404002": "empty event id", SDK_FUNCTIONS_EMPTY_EVENT_ID: -404002, "-404003": "empty poll url", SDK_FUNCTIONS_EMPTY_POLL_URL: -404003, "-404004": "empty poll result json", SDK_FUNCTIONS_EMPTY_POLL_RESULT_JSON: -404004, "-404005": "exceed max poll retry", SDK_FUNCTIONS_EXCEED_MAX_POLL_RETRY: -404005, "-404006": "empty poll result base resp", SDK_FUNCTIONS_EMPTY_POLL_RESULT_BASE_RESP: -404006, "-404007": "poll result base resp ret abnormal", SDK_FUNCTIONS_POLL_RESULT_BASE_RESP_RET_ABNORMAL: -404007, "-404008": "poll result status code error", SDK_FUNCTIONS_POLL_RESULT_STATUS_CODE_ERROR: -404008, "-404009": "poll error", SDK_FUNCTIONS_POLL_ERROR: -404009, "-404010": "result expired", SDK_FUNCTIONS_POLL_RESULT_EXPIRED: -404010, "-404011": "cloud function execution error", SDK_FUNCTIONS_CLOUD_FUNCTION_EXECUTION_ERROR: -404011, "-404012": "polling exceed max timeout retry", SDK_FUNCTIONS_EXCEED_MAX_TIMEOUT_POLL_RETRY: -404012, "-404013": "polling exceed max system error retry", SDK_FUNCTIONS_EXCEED_MAX_SYSTEM_ERROR_POLL_RETRY: -404013, "-601001": "system error", WX_SYSTEM_ERROR: -601001, "-601002": "system args error", WX_SYSTEM_ARGS_ERROR: -601002, "-601003": "system network error", WX_SYSTEM_NETWORK_ERROR: -601003, "-601004": "api permission denied", WX_API_PERMISSION_DENIED: -601004, "-601005": "invalid cloudID", WX_INVALID_CLOUDID: -601005, "-601006": "cloudID expired", WX_CLOUDID_EXPIRED: -601006, "-601007": "cloudID and calling user does not match", WX_CLOUDID_USER_NOT_MATCH: -601007, "-601008": "server-side request timedout", WX_SERVER_REQUEST_TIMEOUT: -601008, "-601009": "missing mobile phone", WX_MISSING_MOBILE_PHONE: -601009, "-601010": "no write permission", WX_NO_WRITE_PERMISSION: -601010, "-601011": "no privilege permission", WX_NO_PRIVILEGE_PERMISSION: -601011, "-601012": "unauthorized env", WX_UNAUTHORIZED_ENV: -601012, "-601013": "no multiend permission", WX_NO_MULTIEND_PERMISSION: -601013, "-601015": "access denied (cloudfunction cloudbase_auth returns empty errCode)", WX_CLOUDBASE_AUTH_RETURN_EMPTY_ERRCODE: -601015, "-601016": "missing env auth info", WX_MISSING_ENV_AUTH_INFO: -601016, "-601017": "access denied (cloudbase_auth returns non-zero errCode)", WX_CLOUDBASE_AUTH_RETURN_NON_ZERO_ERRCODE: -601017, "-602018": "unauthorized API", WX_UNAUTHORIZED_API: -601018, "-602001": "database query result size exceed limit (1MB)", WX_DATABASE_QUERY_SIZE_EXCEED_LIMIT: -602001, "-604001": "cloudfunction result size exceed limit (1MB)", WX_CLOUDFUNCTION_RESULT_SIZE_EXCEED_LIMIT: -604001, "-501001": "resource system error", TCB_RESOURCE_SYSTEM_ERROR: -501001, "-501002": "resource server timeout", TCB_RESOURCE_SERVER_TIMEOUT: -501002, "-501003": "exceed request limit", TCB_EXCEED_REQUEST_LIMIT: -501003, "-501004": "exceed concurrent request limit", TCB_EXCEED_CONCURRENT_REQUEST_LIMIT: -501004, "-501005": "invalid env", TCB_INVALID_ENV: -501005, "-501006": "invalid common parameters", TCB_INVALID_COMMON_PARAM: -501006, "-501007": "invalid parameters", TCB_INVALID_PARAM: -501007, "-501008": "invalid request source", TCB_INVALID_REQUEST_SOURCE: -501008, "-501009": "resource not initialized", TCB_RESOURCE_NOT_INITIALIZED: -501009, "-501010": "tencentcloud key signature verification fail", TCB_KEY_SIGNATURE_VERIFICATION_FAIL: -501010, "-501011": "invalid env status", TCB_INVALID_ENV_STATUS: -501011, "-501012": "invalid api name", TCB_INVALID_API_NAME: -501012, "-501013": "request data size exceeds limit (5M)", TCB_REQ_DATA_EXCEED_LIMIT_5M: -501013, "-501014": "upload file size exceeds limit (5M)", TCB_UPLOAD_FILE_SIZE_EXCEED_LIMIT_5M: -501014, "-501023": "permission denied", TCB_PERMISSION_DENIED: -501023, "-502001": "database request fail", TCB_DB_REQUEST_FAIL: -502001, "-502002": "database invalid command", TCB_DB_INVALID_COMMAND: -502002, "-502003": "database permission denied", TCB_DB_PERMISSION_DENIED: -502003, "-502004": "database exceed collection limit", TCB_DB_EXCEED_COLLECTION_LIMIT: -502004, "-502005": "database collection not exists", TCB_DB_COLLECTION_NOT_EXISTS: -502005, "-503001": "storage request fail", TCB_STORAGE_REQUEST_FAIL: -503001, "-503002": "storage permission denied", TCB_STORAGE_PERMISSION_DENIED: -503002, "-503003": "storage file not exists", TCB_STORAGE_FILE_NOT_EXISTS: -503003, "-503004": "storage invalid sign parameter", TCB_STORAGE_INVALID_SIGN_PARAM: -503004, "-504001": "functions request fail", TCB_FUNCTIONS_REQUEST_FAIL: -504001, "-504002": "functions execute fail", TCB_FUNCTIONS_EXEC_FAIL: -504002 }
}, function(e, t, n) {
    "use strict";
    n.d(t, "a", function() { return f }), n.d(t, "b", function() { return d }), n.d(t, "c", function() { return h }), n.d(t, "e", function() { return p }), n.d(t, "d", function() { return _ });
    var r = n(0),
        i = n(18),
        o = n(9),
        a = n(2),
        s = !1,
        u = [],
        c = "unknown",
        f = function() {
            if (!s) try {
                var e = Object(o.a)();
                e.wx.getNetworkType({ success: function(e) { c = e.networkType }, complete: function() { s = !0, l() } }), e.wx.onNetworkStatusChange(function(e) { s || (s = !0, l()), c = e.networkType })
            } catch (e) { 0 }
        },
        l = function() {
            var e, t;
            try { for (var n = Object(r.g)(u), i = n.next(); !i.done; i = n.next()) { var o = i.value; try { o() } catch (e) { 0 } } } catch (t) { e = { error: t } } finally { try { i && !i.done && (t = n.return) && t.call(n) } finally { if (e) throw e.error } }
            u = []
        },
        d = function(e) {
            setTimeout(function() {
                try {
                    if (! function(e) { return !(e.tunnelStartTime && e.tunnelEndTime && e.tunnelEndTime < e.tunnelStartTime || !(e.apiStartTime && e.apiEndTime && e.apiEndTime > e.apiStartTime)) }(e)) return;
                    if (!s && u.length < 100) return void u.push(d.bind(null, e));
                    var t = e.apiEndTime - e.apiStartTime,
                        n = e.tunnelEndTime ? e.tunnelEndTime - e.tunnelStartTime : 0,
                        r = [0, e.apiName, t, n, (e.pollStartTime && e.pollEndTime && e.pollEndTime > e.pollStartTime ? e.pollEndTime - e.pollStartTime : 0) || 0, c, e.tunnelTimeNoCSNetCost ? t - e.tunnelTimeNoCSNetCost : 0, e.tunnelTimeNoCSNetCost ? n - e.tunnelTimeNoCSNetCost : 0, e.funcExecTime ? e.funcExecTime : 0];
                    i.a.reportKeyValue({ key: "CloudReport", value: r.join(","), force: !0 })
                } catch (e) {}
            })
        },
        h = function(e, t, n, r) { i.a.reportIDKeyDirectly({ id: e, key: t, force: n, immediately: r }) },
        p = function(e, t) {
            var n = Object(a.d)(e);

            function i() {
                for (var r = [], i = 0; i < arguments.length; i++) r[i] = arguments[i];
                if (t.samplePicker && !t.samplePicker.next()) return n ? e.apply(this, r) : e;
                var s = Date.now(),
                    u = !0;
                try {
                    if (t.condition && t.condition.emptyKey && t.timing[t.startKey]) return n ? e.apply(this, r) : e;
                    var c = void 0;
                    if (n) {
                        var f = e.apply(this, r);
                        if (!Object(a.i)(f)) return u = !1, f;
                        c = f
                    } else c = e;
                    return c.then(function() { return o(s) }).catch(function() { return o(s) }), c
                } catch (e) { throw u = !1, e } finally { u || o(s) }
            }

            function o(e) { t.timing[t.startKey] = e, t.timing[t.endKey] = Date.now(), t.autoReport && d(Object(r.a)(Object(r.a)({}, t.timing), { apiName: t.autoReport })) }
            return n ? i : i()
        },
        _ = function(e, t) {
            return function() {
                var n, i;
                return Object(r.d)(this, function(r) {
                    switch (r.label) {
                        case 0:
                            n = function() { return parseInt(Math.round(2 * Math.random() * e), 10) }, i = t ? 0 : n(), r.label = 1;
                        case 1:
                            return i > 0 ? (i--, [4, !1]) : [3, 3];
                        case 2:
                            return r.sent(), [3, 5];
                        case 3:
                            return i = n(), [4, !0];
                        case 4:
                            r.sent(), r.label = 5;
                        case 5:
                            return [3, 1];
                        case 6:
                            return [2]
                    }
                })
            }
        }(10, !0)()
}, function(e, t, n) {
    "use strict";
    n.d(t, "d", function() { return a }), n.d(t, "b", function() { return s }), n.d(t, "c", function() { return u }), n.d(t, "a", function() { return c });
    var r = n(2),
        i = n(1),
        o = n(3);

    function a(e, t, n, a) {
        void 0 === n && (n = "parameter"), void 0 === a && (a = i.b);
        var s = function(e, t, n) {
            void 0 === n && (n = "parameter");
            var i = function e(t, n, i) {
                var o = Object(r.a)(t),
                    a = Object(r.a)(n);
                if ("string" === a) return o !== n ? i + " should be " + n + " instead of " + o + ";" : "";
                if (o !== a) return i + " should be " + a + " instead of " + o + "; ";
                var s = "";
                switch (o) {
                    case "object":
                        for (var u in n) s += e(t[u], n[u], i + "." + u);
                        break;
                    case "array":
                        for (var c = 0; c < n.length; c++) s += e(t[c], n[c], i + "[" + c + "]")
                }
                return s
            }(e, t, n);
            return { passed: !i, reason: i }
        }(e, t, n);
        if (!s.passed) throw new a({ errCode: o.a.SDK_API_PARAMETER_TYPE_ERROR, errMsg: s.reason })
    }

    function s(e, t, n, r) { if (void 0 === r && (r = i.b), void 0 === e || null === e) throw new r({ errCode: o.a.SDK_API_PARAMETER_ERROR, errMsg: "parameter " + t + " of function " + n + " must be provided" }) }

    function u(e) {
        var t = e.name,
            n = e.input,
            r = e.max,
            a = e.maxWording,
            s = void 0 === a ? "" : a,
            u = e.ErrorClass,
            c = void 0 === u ? i.b : u;
        if (n.length > r) throw new c({ errCode: o.a.SDK_API_PARAMETER_ERROR, errMsg: t + " size must be less than " + (s || r) })
    }

    function c(e) {
        var t = e.target,
            n = e.name,
            r = e.ErrorClass,
            a = void 0 === r ? i.b : r;
        if (0 === Object.keys(t).length) throw new a({ errCode: o.a.SDK_API_PARAMETER_ERROR, errMsg: n + " must not be empty" })
    }
}, function(e, t, n) {
    "use strict";
    n.d(t, "c", function() { return a }), n.d(t, "b", function() { return s }), n.d(t, "a", function() { return u });
    var r = n(2),
        i = n(22);

    function o(e, t, n) { t.complete && Object(r.d)(t.complete) && Object(i.c)(t.complete, "at api " + e + " complete callback function;")(n) }

    function a(e, t, n) {! function(e, t, n) { t.success && Object(r.d)(t.success) && Object(i.c)(t.success, "at api " + e + " success callback function;")(n) }(e, t, n), o(e, t, n) }

    function s(e, t, n) {! function(e, t, n) { t.fail && Object(r.d)(t.fail) && Object(i.c)(t.fail, "at api " + e + " fail callback function;")(n) }(e, t, n), o(e, t, n) }

    function u(e) { return e && (e.success || e.fail || e.complete) }
}, function(e, t, n) {
    "use strict";

    function r(e, t) { e.success && e.success(t), e.complete && e.complete(t), e.success = void 0, e.complete = void 0 }

    function i(e, t) { e.fail && e.fail(t), e.complete && e.complete(t), e.fail = void 0, e.complete = void 0 }

    function o(e) {
        var t = {};
        e.getAllResponseHeaders().trim().split(/[\r\n]+/).forEach(function(e) {
            var n = e.split(": "),
                r = n.shift(),
                i = n.join(": ");
            t[r] = i
        })
    }
    n.d(t, "b", function() { return r }), n.d(t, "a", function() { return i }), n.d(t, "c", function() { return o })
}, function(e, t, n) {
    "use strict";
    (function(e, r) {
        n.d(t, "b", function() { return a }), n.d(t, "c", function() { return s });
        var i, o = n(0);
        try { __wxConfig.platform, i = Object(o.a)({}, __wxConfig), __wxConfig.onReady(function() { i = Object.assign(i, __wxConfig) }) } catch (t) { i = { platform: "ios", appLaunchInfo: { mode: "" }, onReady: function(e) { setTimeout(function() { e() }) } }, e.env.TEST && (r.__wxConfig = i) }
        t.a = i;
        var a = function() { return "devtools" === i.platform },
            s = function() { return "mina" === i.vendor }
    }).call(this, n(61), n(32))
}, function(e, t, n) {
    "use strict";
    n.d(t, "a", function() { return a }), n.d(t, "c", function() { return s }), n.d(t, "b", function() { return u });
    var r, i = new WeakMap;

    function o() { return null !== r && void 0 !== r ? r : "undefined" != typeof __appServiceSDK__ ? __appServiceSDK__ : void 0 }
    var a = function(e) { if (!e) return o(); var t = i.get(e); return t && t || o() },
        s = function(e, t) { i.set(e, t) },
        u = function(e) { r = e }
}, function(e, t, n) {
    "use strict";

    function r(e) { return e + ":ok" }

    function i(e, t) { return e + ":fail " + t }
    n.d(t, "b", function() { return r }), n.d(t, "a", function() { return i })
}, function(e, t, n) {
    "use strict";
    var r = n(52),
        i = "object" == typeof self && self && self.Object === Object && self,
        o = r.a || i || Function("return this")();
    t.a = o
}, function(e, t, n) {
    "use strict";
    t.a = function(e) { var t = typeof e; return null != e && ("object" == t || "function" == t) }
}, function(e, t, n) {
    "use strict";
    (function(e) {
        n.d(t, "f", function() { return a }), n.d(t, "b", function() { return s }), n.d(t, "a", function() { return f }), n.d(t, "e", function() { return l }), n.d(t, "d", function() { return p }), n.d(t, "c", function() { return _ });
        var r, i = n(0),
            o = n(9),
            a = function(e) { return void 0 === e && (e = 0), new Promise(function(t) { return setTimeout(t, e) }) },
            s = function() { var e, t, n = Object(o.a)().wx; if (n && n.version) { e = n.version.version, t = n.version.updateTime; var r = n.version.updateTime.match(/^(\d+)\.(\d+)\.(\d+)/); return { version: e, updateTime: t, updateDateInDashes: r ? r[1] + "-" + r[2] + "-" + r[3] : "unknown" } } return { version: "unknown", updateTime: "unknown", updateDateInDashes: "unknown" } },
            u = !1,
            c = [],
            f = function() {
                return new Promise(function(e, t) {
                    if (r) e(r);
                    else {
                        0;
                        try {
                            Object(o.a)().wx.getNetworkType({
                                success: function(t) {
                                    r = { networkType: t.networkType, isConnected: "none" !== t.networkType }, e(r), u || (Object(o.a)().wx.onNetworkStatusChange(function(e) {
                                        if (r.networkType = e.networkType, r.isConnected = e.isConnected, e.isConnected && c.length)
                                            for (; c.length;) try { c.shift()() } catch (e) {}
                                    }), u = !0)
                                },
                                fail: t
                            })
                        } catch (e) { t(e) }
                    }
                })
            },
            l = function() { return new Promise(function(e) { r && r.isConnected ? e() : c.push(e) }) };
        var d = !1,
            h = new Set;

        function p(e) {
            Object(o.a)().wx.onAppShow && (d || (! function() {
                var e = Object(o.a)().wx;
                e.onAppShow && e.onAppHide && (e.onAppShow(function() { var e, t; "visible"; try { for (var n = Object(i.g)(h), r = n.next(); !r.done; r = n.next()) { var o = r.value; try { o("show") } catch (e) { 0 } } } catch (t) { e = { error: t } } finally { try { r && !r.done && (t = n.return) && t.call(n) } finally { if (e) throw e.error } } }), e.onAppHide(function() { var e, t; "hidden"; try { for (var n = Object(i.g)(h), r = n.next(); !r.done; r = n.next()) { var o = r.value; try { o("hide") } catch (e) { 0 } } } catch (t) { e = { error: t } } finally { try { r && !r.done && (t = n.return) && t.call(n) } finally { if (e) throw e.error } } }))
            }(), d = !0), h.size > 50 && h.clear(), h.add(e))
        }

        function _(e) { h.delete(e) }
    }).call(this, n(68).setImmediate)
}, function(e, t, n) {
    "use strict";
    t.a = function(e) { return null != e && "object" == typeof e }
}, function(e, t, n) {
    "use strict";
    n.d(t, "b", function() { return i }), n.d(t, "a", function() { return r });
    var r, i = function(e, t) { var n = new Error(t); return n.errCode = e, n.errMsg = t, n };
    ! function(e) { e[e.INVALID_REFRESH_TOKEN = 40030] = "INVALID_REFRESH_TOKEN", e[e.INVALID_ACCESS_TOKEN = 40014] = "INVALID_ACCESS_TOKEN", e[e.EXPIRED_ACCESS_TOKEN = 42001] = "EXPIRED_ACCESS_TOKEN", e[e.EXPIRED_REFRESH_TOKEN = 42002] = "EXPIRED_REFRESH_TOKEN", e[e.INVALID_CREDENTIAL = 40001] = "INVALID_CREDENTIAL", e[e.INVALID_ARGS = 40097] = "INVALID_ARGS", e[e.NO_SESSION_IN_COOKIE = 85103] = "NO_SESSION_IN_COOKIE" }(r || (r = {}))
}, function(e, t, n) {
    "use strict";
    var r = Array.isArray;
    t.a = r
}, function(e, t, n) {
    "use strict";
    var r = n(33),
        i = n(11).a["__core-js_shared__"],
        o = function() { var e = /[^.]+$/.exec(i && i.keys && i.keys.IE_PROTO || ""); return e ? "Symbol(src)_1." + e : "" }();
    var a = function(e) { return !!o && o in e },
        s = n(12),
        u = n(24),
        c = /^\[object .+?Constructor\]$/,
        f = Function.prototype,
        l = Object.prototype,
        d = f.toString,
        h = l.hasOwnProperty,
        p = RegExp("^" + d.call(h).replace(/[\\^$.*+?()[\]{}|]/g, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$");
    var _ = function(e) { return !(!Object(s.a)(e) || a(e)) && (Object(r.a)(e) ? p : c).test(Object(u.a)(e)) };
    var b = function(e, t) { return null == e ? void 0 : e[t] };
    t.a = function(e, t) { var n = b(e, t); return _(n) ? n : void 0 }
}, function(e, t, n) {
    "use strict";
    var r, i = n(22),
        o = { surroundThirdByTryCatch: function(e, t) { return function() { for (var n = [], r = 0; r < arguments.length; r++) n[r] = arguments[r]; return Object(i.a)(function() { try { return e.apply(e, n) } catch (n) { throw console.error(JSON.stringify(n) + "; " + t + "\n" + n.stack), console.error(e.toString()), n } }, t) } }, reportIDKey: function() { for (var e = [], t = 0; t < arguments.length; t++) e[t] = arguments[t] }, reportIDKeyDirectly: function() { for (var e = [], t = 0; t < arguments.length; t++) e[t] = arguments[t] }, reportKeyValue: function() { for (var e = [], t = 0; t < arguments.length; t++) e[t] = arguments[t] } },
        a = !1,
        s = 10;

    function u() { try { return a ? Reporter : s <= 0 ? r : (s--, Reporter.surroundThirdByTryCatch, r = Reporter, a = !0, r) } catch (e) { return r = o } }
    t.a = { surroundThirdByTryCatch: function(e, t) { return u().surroundThirdByTryCatch(e, t) }, reportIDKey: function(e) { return u().reportIDKey(e) }, reportIDKeyDirectly: function(e) { return u().reportIDKeyDirectly(e) }, reportKeyValue: function(e) { return u().reportKeyValue(e) } }
}, function(e, t, n) {
    "use strict";
    var r = n(20),
        i = Object.prototype,
        o = i.hasOwnProperty,
        a = i.toString,
        s = r.a ? r.a.toStringTag : void 0;
    var u = function(e) {
            var t = o.call(e, s),
                n = e[s];
            try { e[s] = void 0; var r = !0 } catch (e) {}
            var i = a.call(e);
            return r && (t ? e[s] = n : delete e[s]), i
        },
        c = Object.prototype.toString;
    var f = function(e) { return c.call(e) },
        l = "[object Null]",
        d = "[object Undefined]",
        h = r.a ? r.a.toStringTag : void 0;
    t.a = function(e) { return null == e ? void 0 === e ? d : l : h && h in Object(e) ? u(e) : f(e) }
}, function(e, t, n) {
    "use strict";
    var r = n(11).a.Symbol;
    t.a = r
}, function(e, t, n) {
    "use strict";
    var r = n(38),
        i = n(37);
    t.a = function(e, t, n, o) {
        var a = !n;
        n || (n = {});
        for (var s = -1, u = t.length; ++s < u;) {
            var c = t[s],
                f = o ? o(n[c], e[c], c, n, e) : void 0;
            void 0 === f && (f = e[c]), a ? Object(i.a)(n, c, f) : Object(r.a)(n, c, f)
        }
        return n
    }
}, function(e, t, n) {
    "use strict";
    n.d(t, "a", function() { return a }), n.d(t, "c", function() { return s }), n.d(t, "b", function() { return u });
    var r = n(1),
        i = n(2),
        o = n(18);

    function a(e, t) { void 0 === t && (t = ""); try { return e() } catch (e) { if (Object(r.e)(e)) return e.errMsg += t, e; var n = (e ? e.toString() : "") + t; return new r.b({ errMsg: n }) } }

    function s(e, t) {
        return void 0 === t && (t = ""),
            function() { for (var n = [], r = 0; r < arguments.length; r++) n[r] = arguments[r]; return a(function() { return e.apply(e, n) }, t) }
    }

    function u(e) {
        var t = e.param;
        t && (t.success && Object(i.d)(t.success) && (t.success = o.a.surroundThirdByTryCatch(t.success, "at api " + e.apiName + " success callback function")), t.fail && Object(i.d)(t.fail) && (t.fail = o.a.surroundThirdByTryCatch(t.fail, "at api " + e.apiName + " fail callback function")), t.complete && Object(i.d)(t.complete) && (t.complete = o.a.surroundThirdByTryCatch(t.complete, "at api " + e.apiName + " complete callback function")))
    }
}, function(e, t, n) {
    "use strict";
    (function(e) {
        var r = n(52),
            i = "object" == typeof exports && exports && !exports.nodeType && exports,
            o = i && "object" == typeof e && e && !e.nodeType && e,
            a = o && o.exports === i && r.a.process,
            s = function() { try { var e = o && o.require && o.require("util").types; return e || a && a.binding && a.binding("util") } catch (e) {} }();
        t.a = s
    }).call(this, n(62)(e))
}, function(e, t, n) {
    "use strict";
    var r = Function.prototype.toString;
    t.a = function(e) { if (null != e) { try { return r.call(e) } catch (e) {} try { return e + "" } catch (e) {} } return "" }
}, function(e, t, n) {
    "use strict";
    t.a = function(e, t) { return e === t || e != e && t != t }
}, function(e, t, n) {
    "use strict";
    var r = n(33),
        i = n(55);
    t.a = function(e) { return null != e && Object(i.a)(e.length) && !Object(r.a)(e) }
}, function(e, t, n) {
    "use strict";
    var r = function() { this.__data__ = [], this.size = 0 },
        i = n(25);
    var o = function(e, t) {
            for (var n = e.length; n--;)
                if (Object(i.a)(e[n][0], t)) return n;
            return -1
        },
        a = Array.prototype.splice;
    var s = function(e) {
        var t = this.__data__,
            n = o(t, e);
        return !(n < 0 || (n == t.length - 1 ? t.pop() : a.call(t, n, 1), --this.size, 0))
    };
    var u = function(e) {
        var t = this.__data__,
            n = o(t, e);
        return n < 0 ? void 0 : t[n][1]
    };
    var c = function(e) { return o(this.__data__, e) > -1 };
    var f = function(e, t) {
        var n = this.__data__,
            r = o(n, e);
        return r < 0 ? (++this.size, n.push([e, t])) : n[r][1] = t, this
    };

    function l(e) {
        var t = -1,
            n = null == e ? 0 : e.length;
        for (this.clear(); ++t < n;) {
            var r = e[t];
            this.set(r[0], r[1])
        }
    }
    l.prototype.clear = r, l.prototype.delete = s, l.prototype.get = u, l.prototype.has = c, l.prototype.set = f;
    t.a = l
}, function(e, t, n) {
    "use strict";
    var r = n(60),
        i = n(12),
        o = n(35);
    var a = function(e) {
            var t = [];
            if (null != e)
                for (var n in Object(e)) t.push(n);
            return t
        },
        s = Object.prototype.hasOwnProperty;
    var u = function(e) {
            if (!Object(i.a)(e)) return a(e);
            var t = Object(o.a)(e),
                n = [];
            for (var r in e)("constructor" != r || !t && s.call(e, r)) && n.push(r);
            return n
        },
        c = n(26);
    t.a = function(e) { return Object(c.a)(e) ? Object(r.a)(e, !0) : u(e) }
}, function(e, t, n) {
    "use strict";
    var r = n(17),
        i = n(11),
        o = Object(r.a)(i.a, "Map");
    t.a = o
}, function(module, exports, __webpack_require__) {
    (function(global, Buffer) {
        module.exports = function(exports) {
            var lookup = [],
                revLookup = [],
                Arr = "undefined" != typeof Uint8Array ? Uint8Array : Array,
                inited = !1;

            function init() {
                inited = !0;
                for (var e = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", t = 0, n = e.length; t < n; ++t) lookup[t] = e[t], revLookup[e.charCodeAt(t)] = t;
                revLookup["-".charCodeAt(0)] = 62, revLookup["_".charCodeAt(0)] = 63
            }

            function toByteArray(e) {
                var t, n, r, i, o, a;
                inited || init();
                var s = e.length;
                if (s % 4 > 0) throw new Error("Invalid string. Length must be a multiple of 4");
                o = "=" === e[s - 2] ? 2 : "=" === e[s - 1] ? 1 : 0, a = new Arr(3 * s / 4 - o), r = o > 0 ? s - 4 : s;
                var u = 0;
                for (t = 0, n = 0; t < r; t += 4, n += 3) i = revLookup[e.charCodeAt(t)] << 18 | revLookup[e.charCodeAt(t + 1)] << 12 | revLookup[e.charCodeAt(t + 2)] << 6 | revLookup[e.charCodeAt(t + 3)], a[u++] = i >> 16 & 255, a[u++] = i >> 8 & 255, a[u++] = 255 & i;
                return 2 === o ? (i = revLookup[e.charCodeAt(t)] << 2 | revLookup[e.charCodeAt(t + 1)] >> 4, a[u++] = 255 & i) : 1 === o && (i = revLookup[e.charCodeAt(t)] << 10 | revLookup[e.charCodeAt(t + 1)] << 4 | revLookup[e.charCodeAt(t + 2)] >> 2, a[u++] = i >> 8 & 255, a[u++] = 255 & i), a
            }

            function tripletToBase64(e) { return lookup[e >> 18 & 63] + lookup[e >> 12 & 63] + lookup[e >> 6 & 63] + lookup[63 & e] }

            function encodeChunk(e, t, n) { for (var r, i = [], o = t; o < n; o += 3) r = (e[o] << 16) + (e[o + 1] << 8) + e[o + 2], i.push(tripletToBase64(r)); return i.join("") }

            function fromByteArray(e) {
                var t;
                inited || init();
                for (var n = e.length, r = n % 3, i = "", o = [], a = 0, s = n - r; a < s; a += 16383) o.push(encodeChunk(e, a, a + 16383 > s ? s : a + 16383));
                return 1 === r ? (t = e[n - 1], i += lookup[t >> 2], i += lookup[t << 4 & 63], i += "==") : 2 === r && (t = (e[n - 2] << 8) + e[n - 1], i += lookup[t >> 10], i += lookup[t >> 4 & 63], i += lookup[t << 2 & 63], i += "="), o.push(i), o.join("")
            }

            function read(e, t, n, r, i) {
                var o, a, s = 8 * i - r - 1,
                    u = (1 << s) - 1,
                    c = u >> 1,
                    f = -7,
                    l = n ? i - 1 : 0,
                    d = n ? -1 : 1,
                    h = e[t + l];
                for (l += d, o = h & (1 << -f) - 1, h >>= -f, f += s; f > 0; o = 256 * o + e[t + l], l += d, f -= 8);
                for (a = o & (1 << -f) - 1, o >>= -f, f += r; f > 0; a = 256 * a + e[t + l], l += d, f -= 8);
                if (0 === o) o = 1 - c;
                else {
                    if (o === u) return a ? NaN : 1 / 0 * (h ? -1 : 1);
                    a += Math.pow(2, r), o -= c
                }
                return (h ? -1 : 1) * a * Math.pow(2, o - r)
            }

            function write(e, t, n, r, i, o) {
                var a, s, u, c = 8 * o - i - 1,
                    f = (1 << c) - 1,
                    l = f >> 1,
                    d = 23 === i ? Math.pow(2, -24) - Math.pow(2, -77) : 0,
                    h = r ? 0 : o - 1,
                    p = r ? 1 : -1,
                    _ = t < 0 || 0 === t && 1 / t < 0 ? 1 : 0;
                for (t = Math.abs(t), isNaN(t) || t === 1 / 0 ? (s = isNaN(t) ? 1 : 0, a = f) : (a = Math.floor(Math.log(t) / Math.LN2), t * (u = Math.pow(2, -a)) < 1 && (a--, u *= 2), (t += a + l >= 1 ? d / u : d * Math.pow(2, 1 - l)) * u >= 2 && (a++, u /= 2), a + l >= f ? (s = 0, a = f) : a + l >= 1 ? (s = (t * u - 1) * Math.pow(2, i), a += l) : (s = t * Math.pow(2, l - 1) * Math.pow(2, i), a = 0)); i >= 8; e[n + h] = 255 & s, h += p, s /= 256, i -= 8);
                for (a = a << i | s, c += i; c > 0; e[n + h] = 255 & a, h += p, a /= 256, c -= 8);
                e[n + h - p] |= 128 * _
            }
            var toString = {}.toString,
                isArray = Array.isArray || function(e) { return "[object Array]" == toString.call(e) },
                INSPECT_MAX_BYTES = 50;
            Buffer$1.TYPED_ARRAY_SUPPORT = void 0 === global.TYPED_ARRAY_SUPPORT || global.TYPED_ARRAY_SUPPORT;
            var _kMaxLength = kMaxLength();

            function kMaxLength() { return Buffer$1.TYPED_ARRAY_SUPPORT ? 2147483647 : 1073741823 }

            function createBuffer(e, t) { if (kMaxLength() < t) throw new RangeError("Invalid typed array length"); return Buffer$1.TYPED_ARRAY_SUPPORT ? (e = new Uint8Array(t)).__proto__ = Buffer$1.prototype : (null === e && (e = new Buffer$1(t)), e.length = t), e }

            function Buffer$1(e, t, n) { if (!(Buffer$1.TYPED_ARRAY_SUPPORT || this instanceof Buffer$1)) return new Buffer$1(e, t, n); if ("number" == typeof e) { if ("string" == typeof t) throw new Error("If encoding is specified then the first argument must be a string"); return allocUnsafe(this, e) } return from(this, e, t, n) }

            function from(e, t, n, r) { if ("number" == typeof t) throw new TypeError('"value" argument must not be a number'); return "undefined" != typeof ArrayBuffer && t instanceof ArrayBuffer ? fromArrayBuffer(e, t, n, r) : "string" == typeof t ? fromString(e, t, n) : fromObject(e, t) }

            function assertSize(e) { if ("number" != typeof e) throw new TypeError('"size" argument must be a number'); if (e < 0) throw new RangeError('"size" argument must not be negative') }

            function alloc(e, t, n, r) { return assertSize(t), t <= 0 ? createBuffer(e, t) : void 0 !== n ? "string" == typeof r ? createBuffer(e, t).fill(n, r) : createBuffer(e, t).fill(n) : createBuffer(e, t) }

            function allocUnsafe(e, t) {
                if (assertSize(t), e = createBuffer(e, t < 0 ? 0 : 0 | checked(t)), !Buffer$1.TYPED_ARRAY_SUPPORT)
                    for (var n = 0; n < t; ++n) e[n] = 0;
                return e
            }

            function fromString(e, t, n) {
                if ("string" == typeof n && "" !== n || (n = "utf8"), !Buffer$1.isEncoding(n)) throw new TypeError('"encoding" must be a valid string encoding');
                var r = 0 | byteLength(t, n),
                    i = (e = createBuffer(e, r)).write(t, n);
                return i !== r && (e = e.slice(0, i)), e
            }

            function fromArrayLike(e, t) {
                var n = t.length < 0 ? 0 : 0 | checked(t.length);
                e = createBuffer(e, n);
                for (var r = 0; r < n; r += 1) e[r] = 255 & t[r];
                return e
            }

            function fromArrayBuffer(e, t, n, r) { if (t.byteLength, n < 0 || t.byteLength < n) throw new RangeError("'offset' is out of bounds"); if (t.byteLength < n + (r || 0)) throw new RangeError("'length' is out of bounds"); return t = void 0 === n && void 0 === r ? new Uint8Array(t) : void 0 === r ? new Uint8Array(t, n) : new Uint8Array(t, n, r), Buffer$1.TYPED_ARRAY_SUPPORT ? (e = t).__proto__ = Buffer$1.prototype : e = fromArrayLike(e, t), e }

            function fromObject(e, t) { if (internalIsBuffer(t)) { var n = 0 | checked(t.length); return 0 === (e = createBuffer(e, n)).length ? e : (t.copy(e, 0, 0, n), e) } if (t) { if ("undefined" != typeof ArrayBuffer && t.buffer instanceof ArrayBuffer || "length" in t) return "number" != typeof t.length || isnan(t.length) ? createBuffer(e, 0) : fromArrayLike(e, t); if ("Buffer" === t.type && isArray(t.data)) return fromArrayLike(e, t.data) } throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.") }

            function checked(e) { if (e >= kMaxLength()) throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x" + kMaxLength().toString(16) + " bytes"); return 0 | e }

            function SlowBuffer(e) { return +e != e && (e = 0), Buffer$1.alloc(+e) }

            function internalIsBuffer(e) { return !(null == e || !e._isBuffer) }

            function byteLength(e, t) {
                if (internalIsBuffer(e)) return e.length;
                if ("undefined" != typeof ArrayBuffer && "function" == typeof ArrayBuffer.isView && (ArrayBuffer.isView(e) || e instanceof ArrayBuffer)) return e.byteLength;
                "string" != typeof e && (e = "" + e);
                var n = e.length;
                if (0 === n) return 0;
                for (var r = !1;;) switch (t) {
                    case "ascii":
                    case "latin1":
                    case "binary":
                        return n;
                    case "utf8":
                    case "utf-8":
                    case void 0:
                        return utf8ToBytes(e).length;
                    case "ucs2":
                    case "ucs-2":
                    case "utf16le":
                    case "utf-16le":
                        return 2 * n;
                    case "hex":
                        return n >>> 1;
                    case "base64":
                        return base64ToBytes(e).length;
                    default:
                        if (r) return utf8ToBytes(e).length;
                        t = ("" + t).toLowerCase(), r = !0
                }
            }

            function slowToString(e, t, n) {
                var r = !1;
                if ((void 0 === t || t < 0) && (t = 0), t > this.length) return "";
                if ((void 0 === n || n > this.length) && (n = this.length), n <= 0) return "";
                if ((n >>>= 0) <= (t >>>= 0)) return "";
                for (e || (e = "utf8");;) switch (e) {
                    case "hex":
                        return hexSlice(this, t, n);
                    case "utf8":
                    case "utf-8":
                        return utf8Slice(this, t, n);
                    case "ascii":
                        return asciiSlice(this, t, n);
                    case "latin1":
                    case "binary":
                        return latin1Slice(this, t, n);
                    case "base64":
                        return base64Slice(this, t, n);
                    case "ucs2":
                    case "ucs-2":
                    case "utf16le":
                    case "utf-16le":
                        return utf16leSlice(this, t, n);
                    default:
                        if (r) throw new TypeError("Unknown encoding: " + e);
                        e = (e + "").toLowerCase(), r = !0
                }
            }

            function swap(e, t, n) {
                var r = e[t];
                e[t] = e[n], e[n] = r
            }

            function bidirectionalIndexOf(e, t, n, r, i) {
                if (0 === e.length) return -1;
                if ("string" == typeof n ? (r = n, n = 0) : n > 2147483647 ? n = 2147483647 : n < -2147483648 && (n = -2147483648), n = +n, isNaN(n) && (n = i ? 0 : e.length - 1), n < 0 && (n = e.length + n), n >= e.length) {
                    if (i) return -1;
                    n = e.length - 1
                } else if (n < 0) {
                    if (!i) return -1;
                    n = 0
                }
                if ("string" == typeof t && (t = Buffer$1.from(t, r)), internalIsBuffer(t)) return 0 === t.length ? -1 : arrayIndexOf(e, t, n, r, i);
                if ("number" == typeof t) return t &= 255, Buffer$1.TYPED_ARRAY_SUPPORT && "function" == typeof Uint8Array.prototype.indexOf ? i ? Uint8Array.prototype.indexOf.call(e, t, n) : Uint8Array.prototype.lastIndexOf.call(e, t, n) : arrayIndexOf(e, [t], n, r, i);
                throw new TypeError("val must be string, number or Buffer")
            }

            function arrayIndexOf(e, t, n, r, i) {
                var o, a = 1,
                    s = e.length,
                    u = t.length;
                if (void 0 !== r && ("ucs2" === (r = String(r).toLowerCase()) || "ucs-2" === r || "utf16le" === r || "utf-16le" === r)) {
                    if (e.length < 2 || t.length < 2) return -1;
                    a = 2, s /= 2, u /= 2, n /= 2
                }

                function c(e, t) { return 1 === a ? e[t] : e.readUInt16BE(t * a) }
                if (i) {
                    var f = -1;
                    for (o = n; o < s; o++)
                        if (c(e, o) === c(t, -1 === f ? 0 : o - f)) { if (-1 === f && (f = o), o - f + 1 === u) return f * a } else -1 !== f && (o -= o - f), f = -1
                } else
                    for (n + u > s && (n = s - u), o = n; o >= 0; o--) {
                        for (var l = !0, d = 0; d < u; d++)
                            if (c(e, o + d) !== c(t, d)) { l = !1; break }
                        if (l) return o
                    }
                return -1
            }

            function hexWrite(e, t, n, r) {
                n = Number(n) || 0;
                var i = e.length - n;
                r ? (r = Number(r)) > i && (r = i) : r = i;
                var o = t.length;
                if (o % 2 != 0) throw new TypeError("Invalid hex string");
                r > o / 2 && (r = o / 2);
                for (var a = 0; a < r; ++a) {
                    var s = parseInt(t.substr(2 * a, 2), 16);
                    if (isNaN(s)) return a;
                    e[n + a] = s
                }
                return a
            }

            function utf8Write(e, t, n, r) { return blitBuffer(utf8ToBytes(t, e.length - n), e, n, r) }

            function asciiWrite(e, t, n, r) { return blitBuffer(asciiToBytes(t), e, n, r) }

            function latin1Write(e, t, n, r) { return asciiWrite(e, t, n, r) }

            function base64Write(e, t, n, r) { return blitBuffer(base64ToBytes(t), e, n, r) }

            function ucs2Write(e, t, n, r) { return blitBuffer(utf16leToBytes(t, e.length - n), e, n, r) }

            function base64Slice(e, t, n) { return 0 === t && n === e.length ? fromByteArray(e) : fromByteArray(e.slice(t, n)) }

            function utf8Slice(e, t, n) {
                n = Math.min(e.length, n);
                for (var r = [], i = t; i < n;) {
                    var o, a, s, u, c = e[i],
                        f = null,
                        l = c > 239 ? 4 : c > 223 ? 3 : c > 191 ? 2 : 1;
                    if (i + l <= n) switch (l) {
                        case 1:
                            c < 128 && (f = c);
                            break;
                        case 2:
                            128 == (192 & (o = e[i + 1])) && (u = (31 & c) << 6 | 63 & o) > 127 && (f = u);
                            break;
                        case 3:
                            o = e[i + 1], a = e[i + 2], 128 == (192 & o) && 128 == (192 & a) && (u = (15 & c) << 12 | (63 & o) << 6 | 63 & a) > 2047 && (u < 55296 || u > 57343) && (f = u);
                            break;
                        case 4:
                            o = e[i + 1], a = e[i + 2], s = e[i + 3], 128 == (192 & o) && 128 == (192 & a) && 128 == (192 & s) && (u = (15 & c) << 18 | (63 & o) << 12 | (63 & a) << 6 | 63 & s) > 65535 && u < 1114112 && (f = u)
                    }
                    null === f ? (f = 65533, l = 1) : f > 65535 && (f -= 65536, r.push(f >>> 10 & 1023 | 55296), f = 56320 | 1023 & f), r.push(f), i += l
                }
                return decodeCodePointsArray(r)
            }
            Buffer$1.poolSize = 8192, Buffer$1._augment = function(e) { return e.__proto__ = Buffer$1.prototype, e }, Buffer$1.from = function(e, t, n) { return from(null, e, t, n) }, Buffer$1.TYPED_ARRAY_SUPPORT && (Buffer$1.prototype.__proto__ = Uint8Array.prototype, Buffer$1.__proto__ = Uint8Array), Buffer$1.alloc = function(e, t, n) { return alloc(null, e, t, n) }, Buffer$1.allocUnsafe = function(e) { return allocUnsafe(null, e) }, Buffer$1.allocUnsafeSlow = function(e) { return allocUnsafe(null, e) }, Buffer$1.isBuffer = isBuffer, Buffer$1.compare = function(e, t) {
                if (!internalIsBuffer(e) || !internalIsBuffer(t)) throw new TypeError("Arguments must be Buffers");
                if (e === t) return 0;
                for (var n = e.length, r = t.length, i = 0, o = Math.min(n, r); i < o; ++i)
                    if (e[i] !== t[i]) { n = e[i], r = t[i]; break }
                return n < r ? -1 : r < n ? 1 : 0
            }, Buffer$1.isEncoding = function(e) {
                switch (String(e).toLowerCase()) {
                    case "hex":
                    case "utf8":
                    case "utf-8":
                    case "ascii":
                    case "latin1":
                    case "binary":
                    case "base64":
                    case "ucs2":
                    case "ucs-2":
                    case "utf16le":
                    case "utf-16le":
                        return !0;
                    default:
                        return !1
                }
            }, Buffer$1.concat = function(e, t) {
                if (!isArray(e)) throw new TypeError('"list" argument must be an Array of Buffers');
                if (0 === e.length) return Buffer$1.alloc(0);
                var n;
                if (void 0 === t)
                    for (t = 0, n = 0; n < e.length; ++n) t += e[n].length;
                var r = Buffer$1.allocUnsafe(t),
                    i = 0;
                for (n = 0; n < e.length; ++n) {
                    var o = e[n];
                    if (!internalIsBuffer(o)) throw new TypeError('"list" argument must be an Array of Buffers');
                    o.copy(r, i), i += o.length
                }
                return r
            }, Buffer$1.byteLength = byteLength, Buffer$1.prototype._isBuffer = !0, Buffer$1.prototype.swap16 = function() { var e = this.length; if (e % 2 != 0) throw new RangeError("Buffer size must be a multiple of 16-bits"); for (var t = 0; t < e; t += 2) swap(this, t, t + 1); return this }, Buffer$1.prototype.swap32 = function() { var e = this.length; if (e % 4 != 0) throw new RangeError("Buffer size must be a multiple of 32-bits"); for (var t = 0; t < e; t += 4) swap(this, t, t + 3), swap(this, t + 1, t + 2); return this }, Buffer$1.prototype.swap64 = function() { var e = this.length; if (e % 8 != 0) throw new RangeError("Buffer size must be a multiple of 64-bits"); for (var t = 0; t < e; t += 8) swap(this, t, t + 7), swap(this, t + 1, t + 6), swap(this, t + 2, t + 5), swap(this, t + 3, t + 4); return this }, Buffer$1.prototype.toString = function() { var e = 0 | this.length; return 0 === e ? "" : 0 === arguments.length ? utf8Slice(this, 0, e) : slowToString.apply(this, arguments) }, Buffer$1.prototype.equals = function(e) { if (!internalIsBuffer(e)) throw new TypeError("Argument must be a Buffer"); return this === e || 0 === Buffer$1.compare(this, e) }, Buffer$1.prototype.inspect = function() {
                var e = "",
                    t = INSPECT_MAX_BYTES;
                return this.length > 0 && (e = this.toString("hex", 0, t).match(/.{2}/g).join(" "), this.length > t && (e += " ... ")), "<Buffer " + e + ">"
            }, Buffer$1.prototype.compare = function(e, t, n, r, i) {
                if (!internalIsBuffer(e)) throw new TypeError("Argument must be a Buffer");
                if (void 0 === t && (t = 0), void 0 === n && (n = e ? e.length : 0), void 0 === r && (r = 0), void 0 === i && (i = this.length), t < 0 || n > e.length || r < 0 || i > this.length) throw new RangeError("out of range index");
                if (r >= i && t >= n) return 0;
                if (r >= i) return -1;
                if (t >= n) return 1;
                if (t >>>= 0, n >>>= 0, r >>>= 0, i >>>= 0, this === e) return 0;
                for (var o = i - r, a = n - t, s = Math.min(o, a), u = this.slice(r, i), c = e.slice(t, n), f = 0; f < s; ++f)
                    if (u[f] !== c[f]) { o = u[f], a = c[f]; break }
                return o < a ? -1 : a < o ? 1 : 0
            }, Buffer$1.prototype.includes = function(e, t, n) { return -1 !== this.indexOf(e, t, n) }, Buffer$1.prototype.indexOf = function(e, t, n) { return bidirectionalIndexOf(this, e, t, n, !0) }, Buffer$1.prototype.lastIndexOf = function(e, t, n) { return bidirectionalIndexOf(this, e, t, n, !1) }, Buffer$1.prototype.write = function(e, t, n, r) {
                if (void 0 === t) r = "utf8", n = this.length, t = 0;
                else if (void 0 === n && "string" == typeof t) r = t, n = this.length, t = 0;
                else {
                    if (!isFinite(t)) throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");
                    t |= 0, isFinite(n) ? (n |= 0, void 0 === r && (r = "utf8")) : (r = n, n = void 0)
                }
                var i = this.length - t;
                if ((void 0 === n || n > i) && (n = i), e.length > 0 && (n < 0 || t < 0) || t > this.length) throw new RangeError("Attempt to write outside buffer bounds");
                r || (r = "utf8");
                for (var o = !1;;) switch (r) {
                    case "hex":
                        return hexWrite(this, e, t, n);
                    case "utf8":
                    case "utf-8":
                        return utf8Write(this, e, t, n);
                    case "ascii":
                        return asciiWrite(this, e, t, n);
                    case "latin1":
                    case "binary":
                        return latin1Write(this, e, t, n);
                    case "base64":
                        return base64Write(this, e, t, n);
                    case "ucs2":
                    case "ucs-2":
                    case "utf16le":
                    case "utf-16le":
                        return ucs2Write(this, e, t, n);
                    default:
                        if (o) throw new TypeError("Unknown encoding: " + r);
                        r = ("" + r).toLowerCase(), o = !0
                }
            }, Buffer$1.prototype.toJSON = function() { return { type: "Buffer", data: Array.prototype.slice.call(this._arr || this, 0) } };
            var MAX_ARGUMENTS_LENGTH = 4096;

            function decodeCodePointsArray(e) { var t = e.length; if (t <= MAX_ARGUMENTS_LENGTH) return String.fromCharCode.apply(String, e); for (var n = "", r = 0; r < t;) n += String.fromCharCode.apply(String, e.slice(r, r += MAX_ARGUMENTS_LENGTH)); return n }

            function asciiSlice(e, t, n) {
                var r = "";
                n = Math.min(e.length, n);
                for (var i = t; i < n; ++i) r += String.fromCharCode(127 & e[i]);
                return r
            }

            function latin1Slice(e, t, n) {
                var r = "";
                n = Math.min(e.length, n);
                for (var i = t; i < n; ++i) r += String.fromCharCode(e[i]);
                return r
            }

            function hexSlice(e, t, n) {
                var r = e.length;
                (!t || t < 0) && (t = 0), (!n || n < 0 || n > r) && (n = r);
                for (var i = "", o = t; o < n; ++o) i += toHex(e[o]);
                return i
            }

            function utf16leSlice(e, t, n) { for (var r = e.slice(t, n), i = "", o = 0; o < r.length; o += 2) i += String.fromCharCode(r[o] + 256 * r[o + 1]); return i }

            function checkOffset(e, t, n) { if (e % 1 != 0 || e < 0) throw new RangeError("offset is not uint"); if (e + t > n) throw new RangeError("Trying to access beyond buffer length") }

            function checkInt(e, t, n, r, i, o) { if (!internalIsBuffer(e)) throw new TypeError('"buffer" argument must be a Buffer instance'); if (t > i || t < o) throw new RangeError('"value" argument is out of bounds'); if (n + r > e.length) throw new RangeError("Index out of range") }

            function objectWriteUInt16(e, t, n, r) { t < 0 && (t = 65535 + t + 1); for (var i = 0, o = Math.min(e.length - n, 2); i < o; ++i) e[n + i] = (t & 255 << 8 * (r ? i : 1 - i)) >>> 8 * (r ? i : 1 - i) }

            function objectWriteUInt32(e, t, n, r) { t < 0 && (t = 4294967295 + t + 1); for (var i = 0, o = Math.min(e.length - n, 4); i < o; ++i) e[n + i] = t >>> 8 * (r ? i : 3 - i) & 255 }

            function checkIEEE754(e, t, n, r, i, o) { if (n + r > e.length) throw new RangeError("Index out of range"); if (n < 0) throw new RangeError("Index out of range") }

            function writeFloat(e, t, n, r, i) { return i || checkIEEE754(e, t, n, 4, 3.4028234663852886e38, -3.4028234663852886e38), write(e, t, n, r, 23, 4), n + 4 }

            function writeDouble(e, t, n, r, i) { return i || checkIEEE754(e, t, n, 8, 1.7976931348623157e308, -1.7976931348623157e308), write(e, t, n, r, 52, 8), n + 8 }
            Buffer$1.prototype.slice = function(e, t) {
                var n, r = this.length;
                if (e = ~~e, t = void 0 === t ? r : ~~t, e < 0 ? (e += r) < 0 && (e = 0) : e > r && (e = r), t < 0 ? (t += r) < 0 && (t = 0) : t > r && (t = r), t < e && (t = e), Buffer$1.TYPED_ARRAY_SUPPORT)(n = this.subarray(e, t)).__proto__ = Buffer$1.prototype;
                else {
                    var i = t - e;
                    n = new Buffer$1(i, void 0);
                    for (var o = 0; o < i; ++o) n[o] = this[o + e]
                }
                return n
            }, Buffer$1.prototype.readUIntLE = function(e, t, n) { e |= 0, t |= 0, n || checkOffset(e, t, this.length); for (var r = this[e], i = 1, o = 0; ++o < t && (i *= 256);) r += this[e + o] * i; return r }, Buffer$1.prototype.readUIntBE = function(e, t, n) { e |= 0, t |= 0, n || checkOffset(e, t, this.length); for (var r = this[e + --t], i = 1; t > 0 && (i *= 256);) r += this[e + --t] * i; return r }, Buffer$1.prototype.readUInt8 = function(e, t) { return t || checkOffset(e, 1, this.length), this[e] }, Buffer$1.prototype.readUInt16LE = function(e, t) { return t || checkOffset(e, 2, this.length), this[e] | this[e + 1] << 8 }, Buffer$1.prototype.readUInt16BE = function(e, t) { return t || checkOffset(e, 2, this.length), this[e] << 8 | this[e + 1] }, Buffer$1.prototype.readUInt32LE = function(e, t) { return t || checkOffset(e, 4, this.length), (this[e] | this[e + 1] << 8 | this[e + 2] << 16) + 16777216 * this[e + 3] }, Buffer$1.prototype.readUInt32BE = function(e, t) { return t || checkOffset(e, 4, this.length), 16777216 * this[e] + (this[e + 1] << 16 | this[e + 2] << 8 | this[e + 3]) }, Buffer$1.prototype.readIntLE = function(e, t, n) { e |= 0, t |= 0, n || checkOffset(e, t, this.length); for (var r = this[e], i = 1, o = 0; ++o < t && (i *= 256);) r += this[e + o] * i; return r >= (i *= 128) && (r -= Math.pow(2, 8 * t)), r }, Buffer$1.prototype.readIntBE = function(e, t, n) { e |= 0, t |= 0, n || checkOffset(e, t, this.length); for (var r = t, i = 1, o = this[e + --r]; r > 0 && (i *= 256);) o += this[e + --r] * i; return o >= (i *= 128) && (o -= Math.pow(2, 8 * t)), o }, Buffer$1.prototype.readInt8 = function(e, t) { return t || checkOffset(e, 1, this.length), 128 & this[e] ? -1 * (255 - this[e] + 1) : this[e] }, Buffer$1.prototype.readInt16LE = function(e, t) { t || checkOffset(e, 2, this.length); var n = this[e] | this[e + 1] << 8; return 32768 & n ? 4294901760 | n : n }, Buffer$1.prototype.readInt16BE = function(e, t) { t || checkOffset(e, 2, this.length); var n = this[e + 1] | this[e] << 8; return 32768 & n ? 4294901760 | n : n }, Buffer$1.prototype.readInt32LE = function(e, t) { return t || checkOffset(e, 4, this.length), this[e] | this[e + 1] << 8 | this[e + 2] << 16 | this[e + 3] << 24 }, Buffer$1.prototype.readInt32BE = function(e, t) { return t || checkOffset(e, 4, this.length), this[e] << 24 | this[e + 1] << 16 | this[e + 2] << 8 | this[e + 3] }, Buffer$1.prototype.readFloatLE = function(e, t) { return t || checkOffset(e, 4, this.length), read(this, e, !0, 23, 4) }, Buffer$1.prototype.readFloatBE = function(e, t) { return t || checkOffset(e, 4, this.length), read(this, e, !1, 23, 4) }, Buffer$1.prototype.readDoubleLE = function(e, t) { return t || checkOffset(e, 8, this.length), read(this, e, !0, 52, 8) }, Buffer$1.prototype.readDoubleBE = function(e, t) { return t || checkOffset(e, 8, this.length), read(this, e, !1, 52, 8) }, Buffer$1.prototype.writeUIntLE = function(e, t, n, r) {
                (e = +e, t |= 0, n |= 0, r) || checkInt(this, e, t, n, Math.pow(2, 8 * n) - 1, 0);
                var i = 1,
                    o = 0;
                for (this[t] = 255 & e; ++o < n && (i *= 256);) this[t + o] = e / i & 255;
                return t + n
            }, Buffer$1.prototype.writeUIntBE = function(e, t, n, r) {
                (e = +e, t |= 0, n |= 0, r) || checkInt(this, e, t, n, Math.pow(2, 8 * n) - 1, 0);
                var i = n - 1,
                    o = 1;
                for (this[t + i] = 255 & e; --i >= 0 && (o *= 256);) this[t + i] = e / o & 255;
                return t + n
            }, Buffer$1.prototype.writeUInt8 = function(e, t, n) { return e = +e, t |= 0, n || checkInt(this, e, t, 1, 255, 0), Buffer$1.TYPED_ARRAY_SUPPORT || (e = Math.floor(e)), this[t] = 255 & e, t + 1 }, Buffer$1.prototype.writeUInt16LE = function(e, t, n) { return e = +e, t |= 0, n || checkInt(this, e, t, 2, 65535, 0), Buffer$1.TYPED_ARRAY_SUPPORT ? (this[t] = 255 & e, this[t + 1] = e >>> 8) : objectWriteUInt16(this, e, t, !0), t + 2 }, Buffer$1.prototype.writeUInt16BE = function(e, t, n) { return e = +e, t |= 0, n || checkInt(this, e, t, 2, 65535, 0), Buffer$1.TYPED_ARRAY_SUPPORT ? (this[t] = e >>> 8, this[t + 1] = 255 & e) : objectWriteUInt16(this, e, t, !1), t + 2 }, Buffer$1.prototype.writeUInt32LE = function(e, t, n) { return e = +e, t |= 0, n || checkInt(this, e, t, 4, 4294967295, 0), Buffer$1.TYPED_ARRAY_SUPPORT ? (this[t + 3] = e >>> 24, this[t + 2] = e >>> 16, this[t + 1] = e >>> 8, this[t] = 255 & e) : objectWriteUInt32(this, e, t, !0), t + 4 }, Buffer$1.prototype.writeUInt32BE = function(e, t, n) { return e = +e, t |= 0, n || checkInt(this, e, t, 4, 4294967295, 0), Buffer$1.TYPED_ARRAY_SUPPORT ? (this[t] = e >>> 24, this[t + 1] = e >>> 16, this[t + 2] = e >>> 8, this[t + 3] = 255 & e) : objectWriteUInt32(this, e, t, !1), t + 4 }, Buffer$1.prototype.writeIntLE = function(e, t, n, r) {
                if (e = +e, t |= 0, !r) {
                    var i = Math.pow(2, 8 * n - 1);
                    checkInt(this, e, t, n, i - 1, -i)
                }
                var o = 0,
                    a = 1,
                    s = 0;
                for (this[t] = 255 & e; ++o < n && (a *= 256);) e < 0 && 0 === s && 0 !== this[t + o - 1] && (s = 1), this[t + o] = (e / a >> 0) - s & 255;
                return t + n
            }, Buffer$1.prototype.writeIntBE = function(e, t, n, r) {
                if (e = +e, t |= 0, !r) {
                    var i = Math.pow(2, 8 * n - 1);
                    checkInt(this, e, t, n, i - 1, -i)
                }
                var o = n - 1,
                    a = 1,
                    s = 0;
                for (this[t + o] = 255 & e; --o >= 0 && (a *= 256);) e < 0 && 0 === s && 0 !== this[t + o + 1] && (s = 1), this[t + o] = (e / a >> 0) - s & 255;
                return t + n
            }, Buffer$1.prototype.writeInt8 = function(e, t, n) { return e = +e, t |= 0, n || checkInt(this, e, t, 1, 127, -128), Buffer$1.TYPED_ARRAY_SUPPORT || (e = Math.floor(e)), e < 0 && (e = 255 + e + 1), this[t] = 255 & e, t + 1 }, Buffer$1.prototype.writeInt16LE = function(e, t, n) { return e = +e, t |= 0, n || checkInt(this, e, t, 2, 32767, -32768), Buffer$1.TYPED_ARRAY_SUPPORT ? (this[t] = 255 & e, this[t + 1] = e >>> 8) : objectWriteUInt16(this, e, t, !0), t + 2 }, Buffer$1.prototype.writeInt16BE = function(e, t, n) { return e = +e, t |= 0, n || checkInt(this, e, t, 2, 32767, -32768), Buffer$1.TYPED_ARRAY_SUPPORT ? (this[t] = e >>> 8, this[t + 1] = 255 & e) : objectWriteUInt16(this, e, t, !1), t + 2 }, Buffer$1.prototype.writeInt32LE = function(e, t, n) { return e = +e, t |= 0, n || checkInt(this, e, t, 4, 2147483647, -2147483648), Buffer$1.TYPED_ARRAY_SUPPORT ? (this[t] = 255 & e, this[t + 1] = e >>> 8, this[t + 2] = e >>> 16, this[t + 3] = e >>> 24) : objectWriteUInt32(this, e, t, !0), t + 4 }, Buffer$1.prototype.writeInt32BE = function(e, t, n) { return e = +e, t |= 0, n || checkInt(this, e, t, 4, 2147483647, -2147483648), e < 0 && (e = 4294967295 + e + 1), Buffer$1.TYPED_ARRAY_SUPPORT ? (this[t] = e >>> 24, this[t + 1] = e >>> 16, this[t + 2] = e >>> 8, this[t + 3] = 255 & e) : objectWriteUInt32(this, e, t, !1), t + 4 }, Buffer$1.prototype.writeFloatLE = function(e, t, n) { return writeFloat(this, e, t, !0, n) }, Buffer$1.prototype.writeFloatBE = function(e, t, n) { return writeFloat(this, e, t, !1, n) }, Buffer$1.prototype.writeDoubleLE = function(e, t, n) { return writeDouble(this, e, t, !0, n) }, Buffer$1.prototype.writeDoubleBE = function(e, t, n) { return writeDouble(this, e, t, !1, n) }, Buffer$1.prototype.copy = function(e, t, n, r) {
                if (n || (n = 0), r || 0 === r || (r = this.length), t >= e.length && (t = e.length), t || (t = 0), r > 0 && r < n && (r = n), r === n) return 0;
                if (0 === e.length || 0 === this.length) return 0;
                if (t < 0) throw new RangeError("targetStart out of bounds");
                if (n < 0 || n >= this.length) throw new RangeError("sourceStart out of bounds");
                if (r < 0) throw new RangeError("sourceEnd out of bounds");
                r > this.length && (r = this.length), e.length - t < r - n && (r = e.length - t + n);
                var i, o = r - n;
                if (this === e && n < t && t < r)
                    for (i = o - 1; i >= 0; --i) e[i + t] = this[i + n];
                else if (o < 1e3 || !Buffer$1.TYPED_ARRAY_SUPPORT)
                    for (i = 0; i < o; ++i) e[i + t] = this[i + n];
                else Uint8Array.prototype.set.call(e, this.subarray(n, n + o), t);
                return o
            }, Buffer$1.prototype.fill = function(e, t, n, r) {
                if ("string" == typeof e) {
                    if ("string" == typeof t ? (r = t, t = 0, n = this.length) : "string" == typeof n && (r = n, n = this.length), 1 === e.length) {
                        var i = e.charCodeAt(0);
                        i < 256 && (e = i)
                    }
                    if (void 0 !== r && "string" != typeof r) throw new TypeError("encoding must be a string");
                    if ("string" == typeof r && !Buffer$1.isEncoding(r)) throw new TypeError("Unknown encoding: " + r)
                } else "number" == typeof e && (e &= 255);
                if (t < 0 || this.length < t || this.length < n) throw new RangeError("Out of range index");
                if (n <= t) return this;
                var o;
                if (t >>>= 0, n = void 0 === n ? this.length : n >>> 0, e || (e = 0), "number" == typeof e)
                    for (o = t; o < n; ++o) this[o] = e;
                else {
                    var a = internalIsBuffer(e) ? e : utf8ToBytes(new Buffer$1(e, r).toString()),
                        s = a.length;
                    for (o = 0; o < n - t; ++o) this[o + t] = a[o % s]
                }
                return this
            };
            var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g;

            function base64clean(e) { if ((e = stringtrim(e).replace(INVALID_BASE64_RE, "")).length < 2) return ""; for (; e.length % 4 != 0;) e += "="; return e }

            function stringtrim(e) { return e.trim ? e.trim() : e.replace(/^\s+|\s+$/g, "") }

            function toHex(e) { return e < 16 ? "0" + e.toString(16) : e.toString(16) }

            function utf8ToBytes(e, t) {
                var n;
                t = t || 1 / 0;
                for (var r = e.length, i = null, o = [], a = 0; a < r; ++a) {
                    if ((n = e.charCodeAt(a)) > 55295 && n < 57344) {
                        if (!i) {
                            if (n > 56319) {
                                (t -= 3) > -1 && o.push(239, 191, 189);
                                continue
                            }
                            if (a + 1 === r) {
                                (t -= 3) > -1 && o.push(239, 191, 189);
                                continue
                            }
                            i = n;
                            continue
                        }
                        if (n < 56320) {
                            (t -= 3) > -1 && o.push(239, 191, 189), i = n;
                            continue
                        }
                        n = 65536 + (i - 55296 << 10 | n - 56320)
                    } else i && (t -= 3) > -1 && o.push(239, 191, 189);
                    if (i = null, n < 128) {
                        if ((t -= 1) < 0) break;
                        o.push(n)
                    } else if (n < 2048) {
                        if ((t -= 2) < 0) break;
                        o.push(n >> 6 | 192, 63 & n | 128)
                    } else if (n < 65536) {
                        if ((t -= 3) < 0) break;
                        o.push(n >> 12 | 224, n >> 6 & 63 | 128, 63 & n | 128)
                    } else {
                        if (!(n < 1114112)) throw new Error("Invalid code point");
                        if ((t -= 4) < 0) break;
                        o.push(n >> 18 | 240, n >> 12 & 63 | 128, n >> 6 & 63 | 128, 63 & n | 128)
                    }
                }
                return o
            }

            function asciiToBytes(e) { for (var t = [], n = 0; n < e.length; ++n) t.push(255 & e.charCodeAt(n)); return t }

            function utf16leToBytes(e, t) { for (var n, r, i, o = [], a = 0; a < e.length && !((t -= 2) < 0); ++a) r = (n = e.charCodeAt(a)) >> 8, i = n % 256, o.push(i), o.push(r); return o }

            function base64ToBytes(e) { return toByteArray(base64clean(e)) }

            function blitBuffer(e, t, n, r) { for (var i = 0; i < r && !(i + n >= t.length || i >= e.length); ++i) t[i + n] = e[i]; return i }

            function isnan(e) { return e != e }

            function isBuffer(e) { return null != e && (!!e._isBuffer || isFastBuffer(e) || isSlowBuffer(e)) }

            function isFastBuffer(e) { return !!e.constructor && "function" == typeof e.constructor.isBuffer && e.constructor.isBuffer(e) }

            function isSlowBuffer(e) { return "function" == typeof e.readFloatLE && "function" == typeof e.slice && isFastBuffer(e.slice(0, 0)) }
            var bufferEs6 = Object.freeze({ INSPECT_MAX_BYTES: INSPECT_MAX_BYTES, kMaxLength: _kMaxLength, Buffer: Buffer$1, SlowBuffer: SlowBuffer, isBuffer: isBuffer }),
                commonjsGlobal = "undefined" != typeof globalThis ? globalThis : "undefined" != typeof window ? window : void 0 !== global ? global : "undefined" != typeof self ? self : {};

            function createCommonjsModule(e, t) { return e(t = { exports: {} }, t.exports), t.exports }
            var map = Map,
                long_1 = Long,
                wasm = null;

            function Long(e, t, n) { this.low = 0 | e, this.high = 0 | t, this.unsigned = !!n }

            function isLong(e) { return !0 === (e && e.__isLong__) }
            Long.prototype.__isLong__, Object.defineProperty(Long.prototype, "__isLong__", { value: !0 }), Long.isLong = isLong;
            var INT_CACHE = {},
                UINT_CACHE = {};

            function fromInt(e, t) { var n, r, i; return t ? (i = 0 <= (e >>>= 0) && e < 256) && (r = UINT_CACHE[e]) ? r : (n = fromBits(e, (0 | e) < 0 ? -1 : 0, !0), i && (UINT_CACHE[e] = n), n) : (i = -128 <= (e |= 0) && e < 128) && (r = INT_CACHE[e]) ? r : (n = fromBits(e, e < 0 ? -1 : 0, !1), i && (INT_CACHE[e] = n), n) }

            function fromNumber(e, t) { if (isNaN(e)) return t ? UZERO : ZERO; if (t) { if (e < 0) return UZERO; if (e >= TWO_PWR_64_DBL) return MAX_UNSIGNED_VALUE } else { if (e <= -TWO_PWR_63_DBL) return MIN_VALUE; if (e + 1 >= TWO_PWR_63_DBL) return MAX_VALUE } return e < 0 ? fromNumber(-e, t).neg() : fromBits(e % TWO_PWR_32_DBL | 0, e / TWO_PWR_32_DBL | 0, t) }

            function fromBits(e, t, n) { return new Long(e, t, n) }
            Long.fromInt = fromInt, Long.fromNumber = fromNumber, Long.fromBits = fromBits;
            var pow_dbl = Math.pow;

            function fromString$1(e, t, n) {
                if (0 === e.length) throw Error("empty string");
                if ("NaN" === e || "Infinity" === e || "+Infinity" === e || "-Infinity" === e) return ZERO;
                if ("number" == typeof t ? (n = t, t = !1) : t = !!t, (n = n || 10) < 2 || 36 < n) throw RangeError("radix");
                var r;
                if ((r = e.indexOf("-")) > 0) throw Error("interior hyphen");
                if (0 === r) return fromString$1(e.substring(1), t, n).neg();
                for (var i = fromNumber(pow_dbl(n, 8)), o = ZERO, a = 0; a < e.length; a += 8) {
                    var s = Math.min(8, e.length - a),
                        u = parseInt(e.substring(a, a + s), n);
                    if (s < 8) {
                        var c = fromNumber(pow_dbl(n, s));
                        o = o.mul(c).add(fromNumber(u))
                    } else o = (o = o.mul(i)).add(fromNumber(u))
                }
                return o.unsigned = t, o
            }

            function fromValue(e, t) { return "number" == typeof e ? fromNumber(e, t) : "string" == typeof e ? fromString$1(e, t) : fromBits(e.low, e.high, "boolean" == typeof t ? t : e.unsigned) }
            Long.fromString = fromString$1, Long.fromValue = fromValue;
            var TWO_PWR_16_DBL = 65536,
                TWO_PWR_24_DBL = 1 << 24,
                TWO_PWR_32_DBL = TWO_PWR_16_DBL * TWO_PWR_16_DBL,
                TWO_PWR_64_DBL = TWO_PWR_32_DBL * TWO_PWR_32_DBL,
                TWO_PWR_63_DBL = TWO_PWR_64_DBL / 2,
                TWO_PWR_24 = fromInt(TWO_PWR_24_DBL),
                ZERO = fromInt(0);
            Long.ZERO = ZERO;
            var UZERO = fromInt(0, !0);
            Long.UZERO = UZERO;
            var ONE = fromInt(1);
            Long.ONE = ONE;
            var UONE = fromInt(1, !0);
            Long.UONE = UONE;
            var NEG_ONE = fromInt(-1);
            Long.NEG_ONE = NEG_ONE;
            var MAX_VALUE = fromBits(-1, 2147483647, !1);
            Long.MAX_VALUE = MAX_VALUE;
            var MAX_UNSIGNED_VALUE = fromBits(-1, -1, !0);
            Long.MAX_UNSIGNED_VALUE = MAX_UNSIGNED_VALUE;
            var MIN_VALUE = fromBits(0, -2147483648, !1);
            Long.MIN_VALUE = MIN_VALUE;
            var LongPrototype = Long.prototype;
            LongPrototype.toInt = function() { return this.unsigned ? this.low >>> 0 : this.low }, LongPrototype.toNumber = function() { return this.unsigned ? (this.high >>> 0) * TWO_PWR_32_DBL + (this.low >>> 0) : this.high * TWO_PWR_32_DBL + (this.low >>> 0) }, LongPrototype.toString = function(e) {
                if ((e = e || 10) < 2 || 36 < e) throw RangeError("radix");
                if (this.isZero()) return "0";
                if (this.isNegative()) {
                    if (this.eq(MIN_VALUE)) {
                        var t = fromNumber(e),
                            n = this.div(t),
                            r = n.mul(t).sub(this);
                        return n.toString(e) + r.toInt().toString(e)
                    }
                    return "-" + this.neg().toString(e)
                }
                for (var i = fromNumber(pow_dbl(e, 6), this.unsigned), o = this, a = "";;) {
                    var s = o.div(i),
                        u = (o.sub(s.mul(i)).toInt() >>> 0).toString(e);
                    if ((o = s).isZero()) return u + a;
                    for (; u.length < 6;) u = "0" + u;
                    a = "" + u + a
                }
            }, LongPrototype.getHighBits = function() { return this.high }, LongPrototype.getHighBitsUnsigned = function() { return this.high >>> 0 }, LongPrototype.getLowBits = function() { return this.low }, LongPrototype.getLowBitsUnsigned = function() { return this.low >>> 0 }, LongPrototype.getNumBitsAbs = function() { if (this.isNegative()) return this.eq(MIN_VALUE) ? 64 : this.neg().getNumBitsAbs(); for (var e = 0 != this.high ? this.high : this.low, t = 31; t > 0 && 0 == (e & 1 << t); t--); return 0 != this.high ? t + 33 : t + 1 }, LongPrototype.isZero = function() { return 0 === this.high && 0 === this.low }, LongPrototype.eqz = LongPrototype.isZero, LongPrototype.isNegative = function() { return !this.unsigned && this.high < 0 }, LongPrototype.isPositive = function() { return this.unsigned || this.high >= 0 }, LongPrototype.isOdd = function() { return 1 == (1 & this.low) }, LongPrototype.isEven = function() { return 0 == (1 & this.low) }, LongPrototype.equals = function(e) { return isLong(e) || (e = fromValue(e)), (this.unsigned === e.unsigned || this.high >>> 31 != 1 || e.high >>> 31 != 1) && (this.high === e.high && this.low === e.low) }, LongPrototype.eq = LongPrototype.equals, LongPrototype.notEquals = function(e) { return !this.eq(e) }, LongPrototype.neq = LongPrototype.notEquals, LongPrototype.ne = LongPrototype.notEquals, LongPrototype.lessThan = function(e) { return this.comp(e) < 0 }, LongPrototype.lt = LongPrototype.lessThan, LongPrototype.lessThanOrEqual = function(e) { return this.comp(e) <= 0 }, LongPrototype.lte = LongPrototype.lessThanOrEqual, LongPrototype.le = LongPrototype.lessThanOrEqual, LongPrototype.greaterThan = function(e) { return this.comp(e) > 0 }, LongPrototype.gt = LongPrototype.greaterThan, LongPrototype.greaterThanOrEqual = function(e) { return this.comp(e) >= 0 }, LongPrototype.gte = LongPrototype.greaterThanOrEqual, LongPrototype.ge = LongPrototype.greaterThanOrEqual, LongPrototype.compare = function(e) {
                if (isLong(e) || (e = fromValue(e)), this.eq(e)) return 0;
                var t = this.isNegative(),
                    n = e.isNegative();
                return t && !n ? -1 : !t && n ? 1 : this.unsigned ? e.high >>> 0 > this.high >>> 0 || e.high === this.high && e.low >>> 0 > this.low >>> 0 ? -1 : 1 : this.sub(e).isNegative() ? -1 : 1
            }, LongPrototype.comp = LongPrototype.compare, LongPrototype.negate = function() { return !this.unsigned && this.eq(MIN_VALUE) ? MIN_VALUE : this.not().add(ONE) }, LongPrototype.neg = LongPrototype.negate, LongPrototype.add = function(e) {
                isLong(e) || (e = fromValue(e));
                var t = this.high >>> 16,
                    n = 65535 & this.high,
                    r = this.low >>> 16,
                    i = 65535 & this.low,
                    o = e.high >>> 16,
                    a = 65535 & e.high,
                    s = e.low >>> 16,
                    u = 0,
                    c = 0,
                    f = 0,
                    l = 0;
                return f += (l += i + (65535 & e.low)) >>> 16, c += (f += r + s) >>> 16, u += (c += n + a) >>> 16, u += t + o, fromBits((f &= 65535) << 16 | (l &= 65535), (u &= 65535) << 16 | (c &= 65535), this.unsigned)
            }, LongPrototype.subtract = function(e) { return isLong(e) || (e = fromValue(e)), this.add(e.neg()) }, LongPrototype.sub = LongPrototype.subtract, LongPrototype.multiply = function(e) {
                if (this.isZero()) return ZERO;
                if (isLong(e) || (e = fromValue(e)), wasm) return fromBits(wasm.mul(this.low, this.high, e.low, e.high), wasm.get_high(), this.unsigned);
                if (e.isZero()) return ZERO;
                if (this.eq(MIN_VALUE)) return e.isOdd() ? MIN_VALUE : ZERO;
                if (e.eq(MIN_VALUE)) return this.isOdd() ? MIN_VALUE : ZERO;
                if (this.isNegative()) return e.isNegative() ? this.neg().mul(e.neg()) : this.neg().mul(e).neg();
                if (e.isNegative()) return this.mul(e.neg()).neg();
                if (this.lt(TWO_PWR_24) && e.lt(TWO_PWR_24)) return fromNumber(this.toNumber() * e.toNumber(), this.unsigned);
                var t = this.high >>> 16,
                    n = 65535 & this.high,
                    r = this.low >>> 16,
                    i = 65535 & this.low,
                    o = e.high >>> 16,
                    a = 65535 & e.high,
                    s = e.low >>> 16,
                    u = 65535 & e.low,
                    c = 0,
                    f = 0,
                    l = 0,
                    d = 0;
                return l += (d += i * u) >>> 16, f += (l += r * u) >>> 16, l &= 65535, f += (l += i * s) >>> 16, c += (f += n * u) >>> 16, f &= 65535, c += (f += r * s) >>> 16, f &= 65535, c += (f += i * a) >>> 16, c += t * u + n * s + r * a + i * o, fromBits((l &= 65535) << 16 | (d &= 65535), (c &= 65535) << 16 | (f &= 65535), this.unsigned)
            }, LongPrototype.mul = LongPrototype.multiply, LongPrototype.divide = function(e) {
                if (isLong(e) || (e = fromValue(e)), e.isZero()) throw Error("division by zero");
                var t, n, r;
                if (wasm) return this.unsigned || -2147483648 !== this.high || -1 !== e.low || -1 !== e.high ? fromBits((this.unsigned ? wasm.div_u : wasm.div_s)(this.low, this.high, e.low, e.high), wasm.get_high(), this.unsigned) : this;
                if (this.isZero()) return this.unsigned ? UZERO : ZERO;
                if (this.unsigned) {
                    if (e.unsigned || (e = e.toUnsigned()), e.gt(this)) return UZERO;
                    if (e.gt(this.shru(1))) return UONE;
                    r = UZERO
                } else {
                    if (this.eq(MIN_VALUE)) return e.eq(ONE) || e.eq(NEG_ONE) ? MIN_VALUE : e.eq(MIN_VALUE) ? ONE : (t = this.shr(1).div(e).shl(1)).eq(ZERO) ? e.isNegative() ? ONE : NEG_ONE : (n = this.sub(e.mul(t)), r = t.add(n.div(e)));
                    else if (e.eq(MIN_VALUE)) return this.unsigned ? UZERO : ZERO;
                    if (this.isNegative()) return e.isNegative() ? this.neg().div(e.neg()) : this.neg().div(e).neg();
                    if (e.isNegative()) return this.div(e.neg()).neg();
                    r = ZERO
                }
                for (n = this; n.gte(e);) {
                    t = Math.max(1, Math.floor(n.toNumber() / e.toNumber()));
                    for (var i = Math.ceil(Math.log(t) / Math.LN2), o = i <= 48 ? 1 : pow_dbl(2, i - 48), a = fromNumber(t), s = a.mul(e); s.isNegative() || s.gt(n);) s = (a = fromNumber(t -= o, this.unsigned)).mul(e);
                    a.isZero() && (a = ONE), r = r.add(a), n = n.sub(s)
                }
                return r
            }, LongPrototype.div = LongPrototype.divide, LongPrototype.modulo = function(e) { return isLong(e) || (e = fromValue(e)), wasm ? fromBits((this.unsigned ? wasm.rem_u : wasm.rem_s)(this.low, this.high, e.low, e.high), wasm.get_high(), this.unsigned) : this.sub(this.div(e).mul(e)) }, LongPrototype.mod = LongPrototype.modulo, LongPrototype.rem = LongPrototype.modulo, LongPrototype.not = function() { return fromBits(~this.low, ~this.high, this.unsigned) }, LongPrototype.and = function(e) { return isLong(e) || (e = fromValue(e)), fromBits(this.low & e.low, this.high & e.high, this.unsigned) }, LongPrototype.or = function(e) { return isLong(e) || (e = fromValue(e)), fromBits(this.low | e.low, this.high | e.high, this.unsigned) }, LongPrototype.xor = function(e) { return isLong(e) || (e = fromValue(e)), fromBits(this.low ^ e.low, this.high ^ e.high, this.unsigned) }, LongPrototype.shiftLeft = function(e) { return isLong(e) && (e = e.toInt()), 0 == (e &= 63) ? this : e < 32 ? fromBits(this.low << e, this.high << e | this.low >>> 32 - e, this.unsigned) : fromBits(0, this.low << e - 32, this.unsigned) }, LongPrototype.shl = LongPrototype.shiftLeft, LongPrototype.shiftRight = function(e) { return isLong(e) && (e = e.toInt()), 0 == (e &= 63) ? this : e < 32 ? fromBits(this.low >>> e | this.high << 32 - e, this.high >> e, this.unsigned) : fromBits(this.high >> e - 32, this.high >= 0 ? 0 : -1, this.unsigned) }, LongPrototype.shr = LongPrototype.shiftRight, LongPrototype.shiftRightUnsigned = function(e) { if (isLong(e) && (e = e.toInt()), 0 === (e &= 63)) return this; var t = this.high; return e < 32 ? fromBits(this.low >>> e | t << 32 - e, t >>> e, this.unsigned) : fromBits(32 === e ? t : t >>> e - 32, 0, this.unsigned) }, LongPrototype.shru = LongPrototype.shiftRightUnsigned, LongPrototype.shr_u = LongPrototype.shiftRightUnsigned, LongPrototype.toSigned = function() { return this.unsigned ? fromBits(this.low, this.high, !1) : this }, LongPrototype.toUnsigned = function() { return this.unsigned ? this : fromBits(this.low, this.high, !0) }, LongPrototype.toBytes = function(e) { return e ? this.toBytesLE() : this.toBytesBE() }, LongPrototype.toBytesLE = function() {
                var e = this.high,
                    t = this.low;
                return [255 & t, t >>> 8 & 255, t >>> 16 & 255, t >>> 24, 255 & e, e >>> 8 & 255, e >>> 16 & 255, e >>> 24]
            }, LongPrototype.toBytesBE = function() {
                var e = this.high,
                    t = this.low;
                return [e >>> 24, e >>> 16 & 255, e >>> 8 & 255, 255 & e, t >>> 24, t >>> 16 & 255, t >>> 8 & 255, 255 & t]
            }, Long.fromBytes = function(e, t, n) { return n ? Long.fromBytesLE(e, t) : Long.fromBytesBE(e, t) }, Long.fromBytesLE = function(e, t) { return new Long(e[0] | e[1] << 8 | e[2] << 16 | e[3] << 24, e[4] | e[5] << 8 | e[6] << 16 | e[7] << 24, t) }, Long.fromBytesBE = function(e, t) { return new Long(e[4] << 24 | e[5] << 16 | e[6] << 8 | e[7], e[0] << 24 | e[1] << 16 | e[2] << 8 | e[3], t) }, long_1.prototype.toExtendedJSON = function(e) { return e && e.relaxed ? this.toNumber() : { $numberLong: this.toString() } }, long_1.fromExtendedJSON = function(e, t) { var n = long_1.fromString(e.$numberLong); return t && t.relaxed ? n.toNumber() : n }, Object.defineProperty(long_1.prototype, "_bsontype", { value: "Long" });
            var long_1$1 = long_1;

            function _classCallCheck(e, t) { if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function") }

            function _defineProperties(e, t) {
                for (var n = 0; n < t.length; n++) {
                    var r = t[n];
                    r.enumerable = r.enumerable || !1, r.configurable = !0, "value" in r && (r.writable = !0), Object.defineProperty(e, r.key, r)
                }
            }

            function _createClass(e, t, n) { return t && _defineProperties(e.prototype, t), n && _defineProperties(e, n), e }
            var Double = function() {
                function e(t) { _classCallCheck(this, e), t instanceof Number && (t = t.valueOf()), this.value = t }
                return _createClass(e, [{ key: "valueOf", value: function() { return this.value } }, { key: "toJSON", value: function() { return this.value } }, { key: "toExtendedJSON", value: function(e) { return e && (e.legacy || e.relaxed && isFinite(this.value)) ? this.value : { $numberDouble: this.value.toString() } } }], [{ key: "fromExtendedJSON", value: function(t, n) { return n && n.relaxed ? parseFloat(t.$numberDouble) : new e(parseFloat(t.$numberDouble)) } }]), e
            }();
            Object.defineProperty(Double.prototype, "_bsontype", { value: "Double" });
            var double_1 = Double;

            function _typeof(e) { return (_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(e) { return typeof e } : function(e) { return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e })(e) }

            function _classCallCheck$1(e, t) { if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function") }

            function _defineProperties$1(e, t) {
                for (var n = 0; n < t.length; n++) {
                    var r = t[n];
                    r.enumerable = r.enumerable || !1, r.configurable = !0, "value" in r && (r.writable = !0), Object.defineProperty(e, r.key, r)
                }
            }

            function _createClass$1(e, t, n) { return t && _defineProperties$1(e.prototype, t), n && _defineProperties$1(e, n), e }

            function _possibleConstructorReturn(e, t) { return !t || "object" !== _typeof(t) && "function" != typeof t ? _assertThisInitialized(e) : t }

            function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e }

            function _getPrototypeOf(e) { return (_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function(e) { return e.__proto__ || Object.getPrototypeOf(e) })(e) }

            function _inherits(e, t) {
                if ("function" != typeof t && null !== t) throw new TypeError("Super expression must either be null or a function");
                e.prototype = Object.create(t && t.prototype, { constructor: { value: e, writable: !0, configurable: !0 } }), t && _setPrototypeOf(e, t)
            }

            function _setPrototypeOf(e, t) { return (_setPrototypeOf = Object.setPrototypeOf || function(e, t) { return e.__proto__ = t, e })(e, t) }
            var Timestamp = function(e) {
                function t(e, n) { return _classCallCheck$1(this, t), _possibleConstructorReturn(long_1$1.isLong(e) ? _possibleConstructorReturn(this, _getPrototypeOf(t).call(this, e.low, e.high, !0)) : _possibleConstructorReturn(this, _getPrototypeOf(t).call(this, e, n, !0))) }
                return _inherits(t, long_1$1), _createClass$1(t, [{ key: "toJSON", value: function() { return { $timestamp: this.toString() } } }, { key: "toExtendedJSON", value: function() { return { $timestamp: { t: this.high >>> 0, i: this.low >>> 0 } } } }], [{ key: "fromInt", value: function(e) { return new t(long_1$1.fromInt(e, !0)) } }, { key: "fromNumber", value: function(e) { return new t(long_1$1.fromNumber(e, !0)) } }, { key: "fromBits", value: function(e, n) { return new t(e, n) } }, { key: "fromString", value: function(e, n) { return new t(long_1$1.fromString(e, n, !0)) } }, { key: "fromExtendedJSON", value: function(e) { return new t(e.$timestamp.i, e.$timestamp.t) } }]), t
            }();
            Object.defineProperty(Timestamp.prototype, "_bsontype", { value: "Timestamp" }), Timestamp.MAX_VALUE = Timestamp.MAX_UNSIGNED_VALUE;
            var timestamp = Timestamp,
                require$$0 = {};

            function normalizedFunctionString(e) { return e.toString().replace("function(", "function (") }

            function insecureRandomBytes(e) { for (var t = new Uint8Array(e), n = 0; n < e; ++n) t[n] = Math.floor(256 * Math.random()); return t }
            var randomBytes = insecureRandomBytes;
            if ("undefined" != typeof window && window.crypto && window.crypto.getRandomValues) randomBytes = function(e) { return window.crypto.getRandomValues(new Uint8Array(e)) };
            else {
                try { randomBytes = require$$0.randomBytes } catch (e) {}
                null == randomBytes && (randomBytes = insecureRandomBytes)
            }
            var utils = { normalizedFunctionString: normalizedFunctionString, randomBytes: randomBytes };

            function defaultSetTimout() { throw new Error("setTimeout has not been defined") }

            function defaultClearTimeout() { throw new Error("clearTimeout has not been defined") }
            var cachedSetTimeout = defaultSetTimout,
                cachedClearTimeout = defaultClearTimeout;

            function runTimeout(e) { if (cachedSetTimeout === setTimeout) return setTimeout(e, 0); if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) return cachedSetTimeout = setTimeout, setTimeout(e, 0); try { return cachedSetTimeout(e, 0) } catch (t) { try { return cachedSetTimeout.call(null, e, 0) } catch (t) { return cachedSetTimeout.call(this, e, 0) } } }

            function runClearTimeout(e) { if (cachedClearTimeout === clearTimeout) return clearTimeout(e); if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) return cachedClearTimeout = clearTimeout, clearTimeout(e); try { return cachedClearTimeout(e) } catch (t) { try { return cachedClearTimeout.call(null, e) } catch (t) { return cachedClearTimeout.call(this, e) } } }
            "function" == typeof global.setTimeout && (cachedSetTimeout = setTimeout), "function" == typeof global.clearTimeout && (cachedClearTimeout = clearTimeout);
            var queue = [],
                draining = !1,
                currentQueue, queueIndex = -1;

            function cleanUpNextTick() { draining && currentQueue && (draining = !1, currentQueue.length ? queue = currentQueue.concat(queue) : queueIndex = -1, queue.length && drainQueue()) }

            function drainQueue() {
                if (!draining) {
                    var e = runTimeout(cleanUpNextTick);
                    draining = !0;
                    for (var t = queue.length; t;) {
                        for (currentQueue = queue, queue = []; ++queueIndex < t;) currentQueue && currentQueue[queueIndex].run();
                        queueIndex = -1, t = queue.length
                    }
                    currentQueue = null, draining = !1, runClearTimeout(e)
                }
            }

            function nextTick(e) {
                var t = new Array(arguments.length - 1);
                if (arguments.length > 1)
                    for (var n = 1; n < arguments.length; n++) t[n - 1] = arguments[n];
                queue.push(new Item(e, t)), 1 !== queue.length || draining || runTimeout(drainQueue)
            }

            function Item(e, t) { this.fun = e, this.array = t }
            Item.prototype.run = function() { this.fun.apply(null, this.array) };
            var title = "browser",
                platform = "browser",
                browser = !0,
                env = {},
                argv = [],
                version = "",
                versions = {},
                release = {},
                config = {};

            function noop() {}
            var on = noop,
                addListener = noop,
                once = noop,
                off = noop,
                removeListener = noop,
                removeAllListeners = noop,
                emit = noop;

            function binding(e) { throw new Error("process.binding is not supported") }

            function cwd() { return "/" }

            function chdir(e) { throw new Error("process.chdir is not supported") }

            function umask() { return 0 }
            var performance = global.performance || {},
                performanceNow = performance.now || performance.mozNow || performance.msNow || performance.oNow || performance.webkitNow || function() { return (new Date).getTime() };

            function hrtime(e) {
                var t = .001 * performanceNow.call(performance),
                    n = Math.floor(t),
                    r = Math.floor(t % 1 * 1e9);
                return e && (n -= e[0], (r -= e[1]) < 0 && (n--, r += 1e9)), [n, r]
            }
            var startTime = new Date;

            function uptime() { return (new Date - startTime) / 1e3 }
            var process = { nextTick: nextTick, title: title, browser: browser, env: env, argv: argv, version: version, versions: versions, on: on, addListener: addListener, once: once, off: off, removeListener: removeListener, removeAllListeners: removeAllListeners, emit: emit, binding: binding, cwd: cwd, chdir: chdir, umask: umask, hrtime: hrtime, platform: platform, release: release, config: config, uptime: uptime },
                inherits;
            inherits = "function" == typeof Object.create ? function(e, t) { e.super_ = t, e.prototype = Object.create(t.prototype, { constructor: { value: e, enumerable: !1, writable: !0, configurable: !0 } }) } : function(e, t) {
                e.super_ = t;
                var n = function() {};
                n.prototype = t.prototype, e.prototype = new n, e.prototype.constructor = e
            };
            var inherits$1 = inherits;

            function _typeof$1(e) { return (_typeof$1 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(e) { return typeof e } : function(e) { return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e })(e) }
            var formatRegExp = /%[sdj%]/g;

            function format(e) {
                if (!isString(e)) { for (var t = [], n = 0; n < arguments.length; n++) t.push(inspect(arguments[n])); return t.join(" ") }
                n = 1;
                for (var r = arguments, i = r.length, o = String(e).replace(formatRegExp, function(e) {
                        if ("%%" === e) return "%";
                        if (n >= i) return e;
                        switch (e) {
                            case "%s":
                                return String(r[n++]);
                            case "%d":
                                return Number(r[n++]);
                            case "%j":
                                try { return JSON.stringify(r[n++]) } catch (e) { return "[Circular]" }
                            default:
                                return e
                        }
                    }), a = r[n]; n < i; a = r[++n]) isNull(a) || !isObject(a) ? o += " " + a : o += " " + inspect(a);
                return o
            }

            function deprecate(e, t) { if (isUndefined(global.process)) return function() { return deprecate(e, t).apply(this, arguments) }; var n = !1; return function() { return n || (console.error(t), n = !0), e.apply(this, arguments) } }
            var debugs = {},
                debugEnviron;

            function debuglog(e) {
                if (isUndefined(debugEnviron) && (debugEnviron = process.env.NODE_DEBUG || ""), e = e.toUpperCase(), !debugs[e])
                    if (new RegExp("\\b" + e + "\\b", "i").test(debugEnviron)) {
                        debugs[e] = function() {
                            var t = format.apply(null, arguments);
                            console.error("%s %d: %s", e, 0, t)
                        }
                    } else debugs[e] = function() {};
                return debugs[e]
            }

            function inspect(e, t) { var n = { seen: [], stylize: stylizeNoColor }; return arguments.length >= 3 && (n.depth = arguments[2]), arguments.length >= 4 && (n.colors = arguments[3]), isBoolean(t) ? n.showHidden = t : t && _extend(n, t), isUndefined(n.showHidden) && (n.showHidden = !1), isUndefined(n.depth) && (n.depth = 2), isUndefined(n.colors) && (n.colors = !1), isUndefined(n.customInspect) && (n.customInspect = !0), n.colors && (n.stylize = stylizeWithColor), formatValue(n, e, n.depth) }

            function stylizeWithColor(e, t) { var n = inspect.styles[t]; return n ? "[" + inspect.colors[n][0] + "m" + e + "[" + inspect.colors[n][1] + "m" : e }

            function stylizeNoColor(e, t) { return e }

            function arrayToHash(e) { var t = {}; return e.forEach(function(e, n) { t[e] = !0 }), t }

            function formatValue(e, t, n) {
                if (e.customInspect && t && isFunction(t.inspect) && t.inspect !== inspect && (!t.constructor || t.constructor.prototype !== t)) { var r = t.inspect(n, e); return isString(r) || (r = formatValue(e, r, n)), r }
                var i = formatPrimitive(e, t);
                if (i) return i;
                var o = Object.keys(t),
                    a = arrayToHash(o);
                if (e.showHidden && (o = Object.getOwnPropertyNames(t)), isError(t) && (o.indexOf("message") >= 0 || o.indexOf("description") >= 0)) return formatError(t);
                if (0 === o.length) { if (isFunction(t)) { var s = t.name ? ": " + t.name : ""; return e.stylize("[Function" + s + "]", "special") } if (isRegExp(t)) return e.stylize(RegExp.prototype.toString.call(t), "regexp"); if (isDate(t)) return e.stylize(Date.prototype.toString.call(t), "date"); if (isError(t)) return formatError(t) }
                var u, c = "",
                    f = !1,
                    l = ["{", "}"];
                (isArray$1(t) && (f = !0, l = ["[", "]"]), isFunction(t)) && (c = " [Function" + (t.name ? ": " + t.name : "") + "]");
                return isRegExp(t) && (c = " " + RegExp.prototype.toString.call(t)), isDate(t) && (c = " " + Date.prototype.toUTCString.call(t)), isError(t) && (c = " " + formatError(t)), 0 !== o.length || f && 0 != t.length ? n < 0 ? isRegExp(t) ? e.stylize(RegExp.prototype.toString.call(t), "regexp") : e.stylize("[Object]", "special") : (e.seen.push(t), u = f ? formatArray(e, t, n, a, o) : o.map(function(r) { return formatProperty(e, t, n, a, r, f) }), e.seen.pop(), reduceToSingleString(u, c, l)) : l[0] + c + l[1]
            }

            function formatPrimitive(e, t) { if (isUndefined(t)) return e.stylize("undefined", "undefined"); if (isString(t)) { var n = "'" + JSON.stringify(t).replace(/^"|"$/g, "").replace(/'/g, "\\'").replace(/\\"/g, '"') + "'"; return e.stylize(n, "string") } return isNumber(t) ? e.stylize("" + t, "number") : isBoolean(t) ? e.stylize("" + t, "boolean") : isNull(t) ? e.stylize("null", "null") : void 0 }

            function formatError(e) { return "[" + Error.prototype.toString.call(e) + "]" }

            function formatArray(e, t, n, r, i) { for (var o = [], a = 0, s = t.length; a < s; ++a) hasOwnProperty(t, String(a)) ? o.push(formatProperty(e, t, n, r, String(a), !0)) : o.push(""); return i.forEach(function(i) { i.match(/^\d+$/) || o.push(formatProperty(e, t, n, r, i, !0)) }), o }

            function formatProperty(e, t, n, r, i, o) {
                var a, s, u;
                if ((u = Object.getOwnPropertyDescriptor(t, i) || { value: t[i] }).get ? s = u.set ? e.stylize("[Getter/Setter]", "special") : e.stylize("[Getter]", "special") : u.set && (s = e.stylize("[Setter]", "special")), hasOwnProperty(r, i) || (a = "[" + i + "]"), s || (e.seen.indexOf(u.value) < 0 ? (s = isNull(n) ? formatValue(e, u.value, null) : formatValue(e, u.value, n - 1)).indexOf("\n") > -1 && (s = o ? s.split("\n").map(function(e) { return "  " + e }).join("\n").substr(2) : "\n" + s.split("\n").map(function(e) { return "   " + e }).join("\n")) : s = e.stylize("[Circular]", "special")), isUndefined(a)) {
                    if (o && i.match(/^\d+$/)) return s;
                    (a = JSON.stringify("" + i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/) ? (a = a.substr(1, a.length - 2), a = e.stylize(a, "name")) : (a = a.replace(/'/g, "\\'").replace(/\\"/g, '"').replace(/(^"|"$)/g, "'"), a = e.stylize(a, "string"))
                }
                return a + ": " + s
            }

            function reduceToSingleString(e, t, n) { return e.reduce(function(e, t) { return t.indexOf("\n"), e + t.replace(/\u001b\[\d\d?m/g, "").length + 1 }, 0) > 60 ? n[0] + ("" === t ? "" : t + "\n ") + " " + e.join(",\n  ") + " " + n[1] : n[0] + t + " " + e.join(", ") + " " + n[1] }

            function isArray$1(e) { return Array.isArray(e) }

            function isBoolean(e) { return "boolean" == typeof e }

            function isNull(e) { return null === e }

            function isNullOrUndefined(e) { return null == e }

            function isNumber(e) { return "number" == typeof e }

            function isString(e) { return "string" == typeof e }

            function isSymbol(e) { return "symbol" === _typeof$1(e) }

            function isUndefined(e) { return void 0 === e }

            function isRegExp(e) { return isObject(e) && "[object RegExp]" === objectToString(e) }

            function isObject(e) { return "object" === _typeof$1(e) && null !== e }

            function isDate(e) { return isObject(e) && "[object Date]" === objectToString(e) }

            function isError(e) { return isObject(e) && ("[object Error]" === objectToString(e) || e instanceof Error) }

            function isFunction(e) { return "function" == typeof e }

            function isPrimitive(e) { return null === e || "boolean" == typeof e || "number" == typeof e || "string" == typeof e || "symbol" === _typeof$1(e) || void 0 === e }

            function isBuffer$1(e) { return Buffer.isBuffer(e) }

            function objectToString(e) { return Object.prototype.toString.call(e) }

            function pad(e) { return e < 10 ? "0" + e.toString(10) : e.toString(10) }
            inspect.colors = { bold: [1, 22], italic: [3, 23], underline: [4, 24], inverse: [7, 27], white: [37, 39], grey: [90, 39], black: [30, 39], blue: [34, 39], cyan: [36, 39], green: [32, 39], magenta: [35, 39], red: [31, 39], yellow: [33, 39] }, inspect.styles = { special: "cyan", number: "yellow", boolean: "yellow", undefined: "grey", null: "bold", string: "green", date: "magenta", regexp: "red" };
            var months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];

            function timestamp$1() {
                var e = new Date,
                    t = [pad(e.getHours()), pad(e.getMinutes()), pad(e.getSeconds())].join(":");
                return [e.getDate(), months[e.getMonth()], t].join(" ")
            }

            function log() { console.log("%s - %s", timestamp$1(), format.apply(null, arguments)) }

            function _extend(e, t) { if (!t || !isObject(t)) return e; for (var n = Object.keys(t), r = n.length; r--;) e[n[r]] = t[n[r]]; return e }

            function hasOwnProperty(e, t) { return Object.prototype.hasOwnProperty.call(e, t) }
            var util = { inherits: inherits$1, _extend: _extend, log: log, isBuffer: isBuffer$1, isPrimitive: isPrimitive, isFunction: isFunction, isError: isError, isDate: isDate, isObject: isObject, isRegExp: isRegExp, isUndefined: isUndefined, isSymbol: isSymbol, isString: isString, isNumber: isNumber, isNullOrUndefined: isNullOrUndefined, isNull: isNull, isBoolean: isBoolean, isArray: isArray$1, inspect: inspect, deprecate: deprecate, format: format, debuglog: debuglog };

            function _classCallCheck$2(e, t) { if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function") }

            function _defineProperties$2(e, t) {
                for (var n = 0; n < t.length; n++) {
                    var r = t[n];
                    r.enumerable = r.enumerable || !1, r.configurable = !0, "value" in r && (r.writable = !0), Object.defineProperty(e, r.key, r)
                }
            }

            function _createClass$2(e, t, n) { return t && _defineProperties$2(e.prototype, t), n && _defineProperties$2(e, n), e }
            var Buffer$2 = bufferEs6.Buffer,
                randomBytes$1 = utils.randomBytes,
                deprecate$1 = util.deprecate,
                PROCESS_UNIQUE = randomBytes$1(5),
                checkForHexRegExp = new RegExp("^[0-9a-fA-F]{24}$"),
                hasBufferType = !1;
            try { Buffer$2 && Buffer$2.from && (hasBufferType = !0) } catch (e) { hasBufferType = !1 }
            for (var hexTable = [], _i = 0; _i < 256; _i++) hexTable[_i] = (_i <= 15 ? "0" : "") + _i.toString(16);
            for (var decodeLookup = [], i = 0; i < 10;) decodeLookup[48 + i] = i++;
            for (; i < 16;) decodeLookup[55 + i] = decodeLookup[87 + i] = i++;
            var _Buffer = Buffer$2;

            function convertToHex(e) { return e.toString("hex") }

            function makeObjectIdError(e, t) { var n = e[t]; return new TypeError('ObjectId string "'.concat(e, '" contains invalid character "').concat(n, '" with character code (').concat(e.charCodeAt(t), "). All character codes for a non-hex string must be less than 256.")) }
            var ObjectId = function() {
                function e(t) {
                    if (_classCallCheck$2(this, e), t instanceof e) return t;
                    if (null == t || "number" == typeof t) return this.id = e.generate(t), void(e.cacheHexString && (this.__id = this.toString("hex")));
                    var n = e.isValid(t);
                    if (!n && null != t) throw new TypeError("Argument passed in must be a single String of 12 bytes or a string of 24 hex characters");
                    if (n && "string" == typeof t && 24 === t.length && hasBufferType) return new e(Buffer$2.from(t, "hex"));
                    if (n && "string" == typeof t && 24 === t.length) return e.createFromHexString(t);
                    if (null == t || 12 !== t.length) { if (null != t && t.toHexString) return e.createFromHexString(t.toHexString()); throw new TypeError("Argument passed in must be a single String of 12 bytes or a string of 24 hex characters") }
                    this.id = t, e.cacheHexString && (this.__id = this.toString("hex"))
                }
                return _createClass$2(e, [{
                    key: "toHexString",
                    value: function() {
                        if (e.cacheHexString && this.__id) return this.__id;
                        var t = "";
                        if (!this.id || !this.id.length) throw new TypeError("invalid ObjectId, ObjectId.id must be either a string or a Buffer, but is [" + JSON.stringify(this.id) + "]");
                        if (this.id instanceof _Buffer) return t = convertToHex(this.id), e.cacheHexString && (this.__id = t), t;
                        for (var n = 0; n < this.id.length; n++) {
                            var r = hexTable[this.id.charCodeAt(n)];
                            if ("string" != typeof r) throw makeObjectIdError(this.id, n);
                            t += r
                        }
                        return e.cacheHexString && (this.__id = t), t
                    }
                }, { key: "toString", value: function(e) { return this.id && this.id.copy ? this.id.toString("string" == typeof e ? e : "hex") : this.toHexString() } }, { key: "toJSON", value: function() { return this.toHexString() } }, { key: "equals", value: function(t) { return t instanceof e ? this.toString() === t.toString() : "string" == typeof t && e.isValid(t) && 12 === t.length && this.id instanceof _Buffer ? t === this.id.toString("binary") : "string" == typeof t && e.isValid(t) && 24 === t.length ? t.toLowerCase() === this.toHexString() : "string" == typeof t && e.isValid(t) && 12 === t.length ? t === this.id : !(null == t || !(t instanceof e || t.toHexString)) && t.toHexString() === this.toHexString() } }, {
                    key: "getTimestamp",
                    value: function() {
                        var e = new Date,
                            t = this.id.readUInt32BE(0);
                        return e.setTime(1e3 * Math.floor(t)), e
                    }
                }, { key: "toExtendedJSON", value: function() { return this.toHexString ? { $oid: this.toHexString() } : { $oid: this.toString("hex") } } }], [{ key: "getInc", value: function() { return e.index = (e.index + 1) % 16777215 } }, {
                    key: "generate",
                    value: function(t) {
                        "number" != typeof t && (t = ~~(Date.now() / 1e3));
                        var n = e.getInc(),
                            r = Buffer$2.alloc(12);
                        return r[3] = 255 & t, r[2] = t >> 8 & 255, r[1] = t >> 16 & 255, r[0] = t >> 24 & 255, r[4] = PROCESS_UNIQUE[0], r[5] = PROCESS_UNIQUE[1], r[6] = PROCESS_UNIQUE[2], r[7] = PROCESS_UNIQUE[3], r[8] = PROCESS_UNIQUE[4], r[11] = 255 & n, r[10] = n >> 8 & 255, r[9] = n >> 16 & 255, r
                    }
                }, { key: "createPk", value: function() { return new e } }, { key: "createFromTime", value: function(t) { var n = Buffer$2.from([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]); return n[3] = 255 & t, n[2] = t >> 8 & 255, n[1] = t >> 16 & 255, n[0] = t >> 24 & 255, new e(n) } }, { key: "createFromHexString", value: function(t) { if (void 0 === t || null != t && 24 !== t.length) throw new TypeError("Argument passed in must be a single String of 12 bytes or a string of 24 hex characters"); if (hasBufferType) return new e(Buffer$2.from(t, "hex")); for (var n = new _Buffer(12), r = 0, i = 0; i < 24;) n[r++] = decodeLookup[t.charCodeAt(i++)] << 4 | decodeLookup[t.charCodeAt(i++)]; return new e(n) } }, { key: "isValid", value: function(t) { return null != t && ("number" == typeof t || ("string" == typeof t ? 12 === t.length || 24 === t.length && checkForHexRegExp.test(t) : t instanceof e || (t instanceof _Buffer && 12 === t.length || !!t.toHexString && (12 === t.id.length || 24 === t.id.length && checkForHexRegExp.test(t.id))))) } }, { key: "fromExtendedJSON", value: function(t) { return new e(t.$oid) } }]), e
            }();
            ObjectId.get_inc = deprecate$1(function() { return ObjectId.getInc() }, "Please use the static `ObjectId.getInc()` instead"), ObjectId.prototype.get_inc = deprecate$1(function() { return ObjectId.getInc() }, "Please use the static `ObjectId.getInc()` instead"), ObjectId.prototype.getInc = deprecate$1(function() { return ObjectId.getInc() }, "Please use the static `ObjectId.getInc()` instead"), ObjectId.prototype.generate = deprecate$1(function(e) { return ObjectId.generate(e) }, "Please use the static `ObjectId.generate(time)` instead"), Object.defineProperty(ObjectId.prototype, "generationTime", { enumerable: !0, get: function() { return this.id[3] | this.id[2] << 8 | this.id[1] << 16 | this.id[0] << 24 }, set: function(e) { this.id[3] = 255 & e, this.id[2] = e >> 8 & 255, this.id[1] = e >> 16 & 255, this.id[0] = e >> 24 & 255 } }), ObjectId.prototype[util.inspect.custom || "inspect"] = ObjectId.prototype.toString, ObjectId.index = ~~(16777215 * Math.random()), Object.defineProperty(ObjectId.prototype, "_bsontype", { value: "ObjectID" });
            var objectid = ObjectId;

            function _classCallCheck$3(e, t) { if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function") }

            function _defineProperties$3(e, t) {
                for (var n = 0; n < t.length; n++) {
                    var r = t[n];
                    r.enumerable = r.enumerable || !1, r.configurable = !0, "value" in r && (r.writable = !0), Object.defineProperty(e, r.key, r)
                }
            }

            function _createClass$3(e, t, n) { return t && _defineProperties$3(e.prototype, t), n && _defineProperties$3(e, n), e }

            function alphabetize(e) { return e.split("").sort().join("") }
            var BSONRegExp = function() {
                function e(t, n) {
                    _classCallCheck$3(this, e), this.pattern = t || "", this.options = n ? alphabetize(n) : "";
                    for (var r = 0; r < this.options.length; r++)
                        if ("i" !== this.options[r] && "m" !== this.options[r] && "x" !== this.options[r] && "l" !== this.options[r] && "s" !== this.options[r] && "u" !== this.options[r]) throw new Error("The regular expression option [".concat(this.options[r], "] is not supported"))
                }
                return _createClass$3(e, [{ key: "toExtendedJSON", value: function(e) { return (e = e || {}).legacy ? { $regex: this.pattern, $options: this.options } : { $regularExpression: { pattern: this.pattern, options: this.options } } } }], [{ key: "parseOptions", value: function(e) { return e ? e.split("").sort().join("") : "" } }, { key: "fromExtendedJSON", value: function(t) { return t.$regex ? "BSONRegExp" === t.$regex._bsontype ? t : new e(t.$regex, e.parseOptions(t.$options)) : new e(t.$regularExpression.pattern, e.parseOptions(t.$regularExpression.options)) } }]), e
            }();
            Object.defineProperty(BSONRegExp.prototype, "_bsontype", { value: "BSONRegExp" });
            var regexp = BSONRegExp;

            function _classCallCheck$4(e, t) { if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function") }

            function _defineProperties$4(e, t) {
                for (var n = 0; n < t.length; n++) {
                    var r = t[n];
                    r.enumerable = r.enumerable || !1, r.configurable = !0, "value" in r && (r.writable = !0), Object.defineProperty(e, r.key, r)
                }
            }

            function _createClass$4(e, t, n) { return t && _defineProperties$4(e.prototype, t), n && _defineProperties$4(e, n), e }
            var BSONSymbol = function() {
                function e(t) { _classCallCheck$4(this, e), this.value = t }
                return _createClass$4(e, [{ key: "valueOf", value: function() { return this.value } }, { key: "toString", value: function() { return this.value } }, { key: "inspect", value: function() { return this.value } }, { key: "toJSON", value: function() { return this.value } }, { key: "toExtendedJSON", value: function() { return { $symbol: this.value } } }], [{ key: "fromExtendedJSON", value: function(t) { return new e(t.$symbol) } }]), e
            }();
            Object.defineProperty(BSONSymbol.prototype, "_bsontype", { value: "Symbol" });
            var symbol = BSONSymbol;

            function _classCallCheck$5(e, t) { if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function") }

            function _defineProperties$5(e, t) {
                for (var n = 0; n < t.length; n++) {
                    var r = t[n];
                    r.enumerable = r.enumerable || !1, r.configurable = !0, "value" in r && (r.writable = !0), Object.defineProperty(e, r.key, r)
                }
            }

            function _createClass$5(e, t, n) { return t && _defineProperties$5(e.prototype, t), n && _defineProperties$5(e, n), e }
            var Int32 = function() {
                function e(t) { _classCallCheck$5(this, e), t instanceof Number && (t = t.valueOf()), this.value = t }
                return _createClass$5(e, [{ key: "valueOf", value: function() { return this.value } }, { key: "toJSON", value: function() { return this.value } }, { key: "toExtendedJSON", value: function(e) { return e && (e.relaxed || e.legacy) ? this.value : { $numberInt: this.value.toString() } } }], [{ key: "fromExtendedJSON", value: function(t, n) { return n && n.relaxed ? parseInt(t.$numberInt, 10) : new e(t.$numberInt) } }]), e
            }();
            Object.defineProperty(Int32.prototype, "_bsontype", { value: "Int32" });
            var int_32 = Int32;

            function _classCallCheck$6(e, t) { if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function") }

            function _defineProperties$6(e, t) {
                for (var n = 0; n < t.length; n++) {
                    var r = t[n];
                    r.enumerable = r.enumerable || !1, r.configurable = !0, "value" in r && (r.writable = !0), Object.defineProperty(e, r.key, r)
                }
            }

            function _createClass$6(e, t, n) { return t && _defineProperties$6(e.prototype, t), n && _defineProperties$6(e, n), e }
            var Code = function() {
                function e(t, n) { _classCallCheck$6(this, e), this.code = t, this.scope = n }
                return _createClass$6(e, [{ key: "toJSON", value: function() { return { scope: this.scope, code: this.code } } }, { key: "toExtendedJSON", value: function() { return this.scope ? { $code: this.code, $scope: this.scope } : { $code: this.code } } }], [{ key: "fromExtendedJSON", value: function(t) { return new e(t.$code, t.$scope) } }]), e
            }();
            Object.defineProperty(Code.prototype, "_bsontype", { value: "Code" });
            var code = Code,
                Buffer$3 = bufferEs6.Buffer,
                PARSE_STRING_REGEXP = /^(\+|-)?(\d+|(\d*\.\d*))?(E|e)?([-+])?(\d+)?$/,
                PARSE_INF_REGEXP = /^(\+|-)?(Infinity|inf)$/i,
                PARSE_NAN_REGEXP = /^(\+|-)?NaN$/i,
                EXPONENT_MAX = 6111,
                EXPONENT_MIN = -6176,
                EXPONENT_BIAS = 6176,
                MAX_DIGITS = 34,
                NAN_BUFFER = [124, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0].reverse(),
                INF_NEGATIVE_BUFFER = [248, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0].reverse(),
                INF_POSITIVE_BUFFER = [120, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0].reverse(),
                EXPONENT_REGEX = /^([-+])?(\d+)?$/;

            function isDigit(e) { return !isNaN(parseInt(e, 10)) }

            function divideu128(e) {
                var t = long_1$1.fromNumber(1e9),
                    n = long_1$1.fromNumber(0);
                if (!(e.parts[0] || e.parts[1] || e.parts[2] || e.parts[3])) return { quotient: e, rem: n };
                for (var r = 0; r <= 3; r++) n = (n = n.shiftLeft(32)).add(new long_1$1(e.parts[r], 0)), e.parts[r] = n.div(t).low, n = n.modulo(t);
                return { quotient: e, rem: n }
            }

            function multiply64x2(e, t) {
                if (!e && !t) return { high: long_1$1.fromNumber(0), low: long_1$1.fromNumber(0) };
                var n = e.shiftRightUnsigned(32),
                    r = new long_1$1(e.getLowBits(), 0),
                    i = t.shiftRightUnsigned(32),
                    o = new long_1$1(t.getLowBits(), 0),
                    a = n.multiply(i),
                    s = n.multiply(o),
                    u = r.multiply(i),
                    c = r.multiply(o);
                return a = a.add(s.shiftRightUnsigned(32)), s = new long_1$1(s.getLowBits(), 0).add(u).add(c.shiftRightUnsigned(32)), { high: a = a.add(s.shiftRightUnsigned(32)), low: c = s.shiftLeft(32).add(new long_1$1(c.getLowBits(), 0)) }
            }

            function lessThan(e, t) {
                var n = e.high >>> 0,
                    r = t.high >>> 0;
                return n < r || n === r && e.low >>> 0 < t.low >>> 0
            }

            function invalidErr(e, t) { throw new TypeError('"'.concat(e, '" is not a valid Decimal128 string - ').concat(t)) }

            function Decimal128(e) { this.bytes = e }
            Decimal128.fromString = function(e) {
                var t, n = !1,
                    r = !1,
                    i = !1,
                    o = 0,
                    a = 0,
                    s = 0,
                    u = 0,
                    c = 0,
                    f = [0],
                    l = 0,
                    d = 0,
                    h = 0,
                    p = 0,
                    _ = 0,
                    b = 0,
                    g = [0, 0],
                    E = [0, 0],
                    O = 0;
                if (e.length >= 7e3) throw new TypeError(e + " not a valid Decimal128 string");
                var y = e.match(PARSE_STRING_REGEXP),
                    m = e.match(PARSE_INF_REGEXP),
                    T = e.match(PARSE_NAN_REGEXP);
                if (!y && !m && !T || 0 === e.length) throw new TypeError(e + " not a valid Decimal128 string");
                if (y) {
                    var v = y[2],
                        S = y[4],
                        N = y[5],
                        I = y[6];
                    S && void 0 === I && invalidErr(e, "missing exponent power"), S && void 0 === v && invalidErr(e, "missing exponent base"), void 0 === S && (N || I) && invalidErr(e, "missing e before exponent")
                }
                if ("+" !== e[O] && "-" !== e[O] || (n = "-" === e[O++]), !isDigit(e[O]) && "." !== e[O]) { if ("i" === e[O] || "I" === e[O]) return new Decimal128(Buffer$3.from(n ? INF_NEGATIVE_BUFFER : INF_POSITIVE_BUFFER)); if ("N" === e[O]) return new Decimal128(Buffer$3.from(NAN_BUFFER)) }
                for (; isDigit(e[O]) || "." === e[O];) "." !== e[O] ? (l < 34 && ("0" !== e[O] || i) && (i || (c = a), i = !0, f[d++] = parseInt(e[O], 10), l += 1), i && (s += 1), r && (u += 1), a += 1, O += 1) : (r && invalidErr(e, "contains multiple periods"), r = !0, O += 1);
                if (r && !a) throw new TypeError(e + " not a valid Decimal128 string");
                if ("e" === e[O] || "E" === e[O]) {
                    var A = e.substr(++O).match(EXPONENT_REGEX);
                    if (!A || !A[2]) return new Decimal128(Buffer$3.from(NAN_BUFFER));
                    _ = parseInt(A[0], 10), O += A[0].length
                }
                if (e[O]) return new Decimal128(Buffer$3.from(NAN_BUFFER));
                if (h = 0, l) {
                    if (p = l - 1, 1 !== (o = s))
                        for (;
                            "0" === e[c + o - 1];) o -= 1
                } else h = 0, p = 0, f[0] = 0, s = 1, l = 1, o = 0;
                for (_ <= u && u - _ > 16384 ? _ = EXPONENT_MIN : _ -= u; _ > EXPONENT_MAX;) {
                    if ((p += 1) - h > MAX_DIGITS) {
                        if (f.join("").match(/^0+$/)) { _ = EXPONENT_MAX; break }
                        invalidErr(e, "overflow")
                    }
                    _ -= 1
                }
                for (; _ < EXPONENT_MIN || l < s;) {
                    if (0 === p && o < l) { _ = EXPONENT_MIN, o = 0; break }
                    if (l < s ? s -= 1 : p -= 1, _ < EXPONENT_MAX) _ += 1;
                    else {
                        if (f.join("").match(/^0+$/)) { _ = EXPONENT_MAX; break }
                        invalidErr(e, "overflow")
                    }
                }
                if (p - h + 1 < o) {
                    var w = a;
                    r && (c += 1, w += 1), n && (c += 1, w += 1);
                    var R = parseInt(e[c + p + 1], 10),
                        C = 0;
                    if (R >= 5 && (C = 1, 5 === R))
                        for (C = f[p] % 2 == 1, b = c + p + 2; b < w; b++)
                            if (parseInt(e[b], 10)) { C = 1; break }
                    if (C)
                        for (var D = p; D >= 0; D--)
                            if (++f[D] > 9 && (f[D] = 0, 0 === D)) {
                                if (!(_ < EXPONENT_MAX)) return new Decimal128(Buffer$3.from(n ? INF_NEGATIVE_BUFFER : INF_POSITIVE_BUFFER));
                                _ += 1, f[D] = 1
                            }
                }
                if (g = long_1$1.fromNumber(0), E = long_1$1.fromNumber(0), 0 === o) g = long_1$1.fromNumber(0), E = long_1$1.fromNumber(0);
                else if (p - h < 17) { var B = h; for (E = long_1$1.fromNumber(f[B++]), g = new long_1$1(0, 0); B <= p; B++) E = (E = E.multiply(long_1$1.fromNumber(10))).add(long_1$1.fromNumber(f[B])) } else { var L = h; for (g = long_1$1.fromNumber(f[L++]); L <= p - 17; L++) g = (g = g.multiply(long_1$1.fromNumber(10))).add(long_1$1.fromNumber(f[L])); for (E = long_1$1.fromNumber(f[L++]); L <= p; L++) E = (E = E.multiply(long_1$1.fromNumber(10))).add(long_1$1.fromNumber(f[L])) }
                var j = multiply64x2(g, long_1$1.fromString("100000000000000000"));
                j.low = j.low.add(E), lessThan(j.low, E) && (j.high = j.high.add(long_1$1.fromNumber(1))), t = _ + EXPONENT_BIAS;
                var P = { low: long_1$1.fromNumber(0), high: long_1$1.fromNumber(0) };
                j.high.shiftRightUnsigned(49).and(long_1$1.fromNumber(1)).equals(long_1$1.fromNumber(1)) ? (P.high = P.high.or(long_1$1.fromNumber(3).shiftLeft(61)), P.high = P.high.or(long_1$1.fromNumber(t).and(long_1$1.fromNumber(16383).shiftLeft(47))), P.high = P.high.or(j.high.and(long_1$1.fromNumber(0x7fffffffffff)))) : (P.high = P.high.or(long_1$1.fromNumber(16383 & t).shiftLeft(49)), P.high = P.high.or(j.high.and(long_1$1.fromNumber(562949953421311)))), P.low = j.low, n && (P.high = P.high.or(long_1$1.fromString("9223372036854775808")));
                var M = Buffer$3.alloc(16);
                return O = 0, M[O++] = 255 & P.low.low, M[O++] = P.low.low >> 8 & 255, M[O++] = P.low.low >> 16 & 255, M[O++] = P.low.low >> 24 & 255, M[O++] = 255 & P.low.high, M[O++] = P.low.high >> 8 & 255, M[O++] = P.low.high >> 16 & 255, M[O++] = P.low.high >> 24 & 255, M[O++] = 255 & P.high.low, M[O++] = P.high.low >> 8 & 255, M[O++] = P.high.low >> 16 & 255, M[O++] = P.high.low >> 24 & 255, M[O++] = 255 & P.high.high, M[O++] = P.high.high >> 8 & 255, M[O++] = P.high.high >> 16 & 255, M[O++] = P.high.high >> 24 & 255, new Decimal128(M)
            };
            var COMBINATION_MASK = 31,
                EXPONENT_MASK = 16383,
                COMBINATION_INFINITY = 30,
                COMBINATION_NAN = 31;
            Decimal128.prototype.toString = function() {
                for (var e, t, n, r, i, o, a = 0, s = new Array(36), u = 0; u < s.length; u++) s[u] = 0;
                var c, f, l, d, h, p = 0,
                    _ = !1,
                    b = { parts: new Array(4) },
                    g = [];
                p = 0;
                var E = this.bytes;
                if (r = E[p++] | E[p++] << 8 | E[p++] << 16 | E[p++] << 24, n = E[p++] | E[p++] << 8 | E[p++] << 16 | E[p++] << 24, t = E[p++] | E[p++] << 8 | E[p++] << 16 | E[p++] << 24, e = E[p++] | E[p++] << 8 | E[p++] << 16 | E[p++] << 24, p = 0, { low: new long_1$1(r, n), high: new long_1$1(t, e) }.high.lessThan(long_1$1.ZERO) && g.push("-"), (i = e >> 26 & COMBINATION_MASK) >> 3 == 3) {
                    if (i === COMBINATION_INFINITY) return g.join("") + "Infinity";
                    if (i === COMBINATION_NAN) return "NaN";
                    o = e >> 15 & EXPONENT_MASK, l = 8 + (e >> 14 & 1)
                } else l = e >> 14 & 7, o = e >> 17 & EXPONENT_MASK;
                if (c = o - EXPONENT_BIAS, b.parts[0] = (16383 & e) + ((15 & l) << 14), b.parts[1] = t, b.parts[2] = n, b.parts[3] = r, 0 === b.parts[0] && 0 === b.parts[1] && 0 === b.parts[2] && 0 === b.parts[3]) _ = !0;
                else
                    for (h = 3; h >= 0; h--) {
                        var O = 0,
                            y = divideu128(b);
                        if (b = y.quotient, O = y.rem.low)
                            for (d = 8; d >= 0; d--) s[9 * h + d] = O % 10, O = Math.floor(O / 10)
                    }
                if (_) a = 1, s[p] = 0;
                else
                    for (a = 36; !s[p];) a -= 1, p += 1;
                if ((f = a - 1 + c) >= 34 || f <= -7 || c > 0) {
                    if (a > 34) return g.push(0), c > 0 ? g.push("E+" + c) : c < 0 && g.push("E" + c), g.join("");
                    g.push(s[p++]), (a -= 1) && g.push(".");
                    for (var m = 0; m < a; m++) g.push(s[p++]);
                    g.push("E"), f > 0 ? g.push("+" + f) : g.push(f)
                } else if (c >= 0)
                    for (var T = 0; T < a; T++) g.push(s[p++]);
                else {
                    var v = a + c;
                    if (v > 0)
                        for (var S = 0; S < v; S++) g.push(s[p++]);
                    else g.push("0");
                    for (g.push("."); v++ < 0;) g.push("0");
                    for (var N = 0; N < a - Math.max(v - 1, 0); N++) g.push(s[p++])
                }
                return g.join("")
            }, Decimal128.prototype.toJSON = function() { return { $numberDecimal: this.toString() } }, Decimal128.prototype.toExtendedJSON = function() { return { $numberDecimal: this.toString() } }, Decimal128.fromExtendedJSON = function(e) { return Decimal128.fromString(e.$numberDecimal) }, Object.defineProperty(Decimal128.prototype, "_bsontype", { value: "Decimal128" });
            var decimal128 = Decimal128;

            function _classCallCheck$7(e, t) { if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function") }

            function _defineProperties$7(e, t) {
                for (var n = 0; n < t.length; n++) {
                    var r = t[n];
                    r.enumerable = r.enumerable || !1, r.configurable = !0, "value" in r && (r.writable = !0), Object.defineProperty(e, r.key, r)
                }
            }

            function _createClass$7(e, t, n) { return t && _defineProperties$7(e.prototype, t), n && _defineProperties$7(e, n), e }
            var MinKey = function() {
                function e() { _classCallCheck$7(this, e) }
                return _createClass$7(e, [{ key: "toExtendedJSON", value: function() { return { $minKey: 1 } } }], [{ key: "fromExtendedJSON", value: function() { return new e } }]), e
            }();
            Object.defineProperty(MinKey.prototype, "_bsontype", { value: "MinKey" });
            var min_key = MinKey;

            function _classCallCheck$8(e, t) { if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function") }

            function _defineProperties$8(e, t) {
                for (var n = 0; n < t.length; n++) {
                    var r = t[n];
                    r.enumerable = r.enumerable || !1, r.configurable = !0, "value" in r && (r.writable = !0), Object.defineProperty(e, r.key, r)
                }
            }

            function _createClass$8(e, t, n) { return t && _defineProperties$8(e.prototype, t), n && _defineProperties$8(e, n), e }
            var MaxKey = function() {
                function e() { _classCallCheck$8(this, e) }
                return _createClass$8(e, [{ key: "toExtendedJSON", value: function() { return { $maxKey: 1 } } }], [{ key: "fromExtendedJSON", value: function() { return new e } }]), e
            }();
            Object.defineProperty(MaxKey.prototype, "_bsontype", { value: "MaxKey" });
            var max_key = MaxKey;

            function _classCallCheck$9(e, t) { if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function") }

            function _defineProperties$9(e, t) {
                for (var n = 0; n < t.length; n++) {
                    var r = t[n];
                    r.enumerable = r.enumerable || !1, r.configurable = !0, "value" in r && (r.writable = !0), Object.defineProperty(e, r.key, r)
                }
            }

            function _createClass$9(e, t, n) { return t && _defineProperties$9(e.prototype, t), n && _defineProperties$9(e, n), e }
            var DBRef = function() {
                function e(t, n, r, i) {
                    _classCallCheck$9(this, e);
                    var o = t.split(".");
                    2 === o.length && (r = o.shift(), t = o.shift()), this.collection = t, this.oid = n, this.db = r, this.fields = i || {}
                }
                return _createClass$9(e, [{ key: "toJSON", value: function() { var e = Object.assign({ $ref: this.collection, $id: this.oid }, this.fields); return null != this.db && (e.$db = this.db), e } }, { key: "toExtendedJSON", value: function(e) { e = e || {}; var t = { $ref: this.collection, $id: this.oid }; return e.legacy ? t : (this.db && (t.$db = this.db), t = Object.assign(t, this.fields)) } }], [{ key: "fromExtendedJSON", value: function(t) { var n = Object.assign({}, t); return ["$ref", "$id", "$db"].forEach(function(e) { return delete n[e] }), new e(t.$ref, t.$id, t.$db, n) } }]), e
            }();
            Object.defineProperty(DBRef.prototype, "_bsontype", { value: "DBRef" }), Object.defineProperty(DBRef.prototype, "namespace", { get: function() { return this.collection }, set: function(e) { this.collection = e }, configurable: !1 });
            var db_ref = DBRef;

            function _classCallCheck$a(e, t) { if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function") }

            function _defineProperties$a(e, t) {
                for (var n = 0; n < t.length; n++) {
                    var r = t[n];
                    r.enumerable = r.enumerable || !1, r.configurable = !0, "value" in r && (r.writable = !0), Object.defineProperty(e, r.key, r)
                }
            }

            function _createClass$a(e, t, n) { return t && _defineProperties$a(e.prototype, t), n && _defineProperties$a(e, n), e }
            var Buffer$4 = bufferEs6.Buffer,
                Binary = function() {
                    function e(t, n) {
                        if (_classCallCheck$a(this, e), !(null == t || "string" == typeof t || Buffer$4.isBuffer(t) || t instanceof Uint8Array || Array.isArray(t))) throw new TypeError("only String, Buffer, Uint8Array or Array accepted");
                        if (this.sub_type = null == n ? BSON_BINARY_SUBTYPE_DEFAULT : n, this.position = 0, null == t || t instanceof Number) void 0 !== Buffer$4 ? this.buffer = Buffer$4.alloc(e.BUFFER_SIZE) : "undefined" != typeof Uint8Array ? this.buffer = new Uint8Array(new ArrayBuffer(e.BUFFER_SIZE)) : this.buffer = new Array(e.BUFFER_SIZE);
                        else {
                            if ("string" == typeof t)
                                if (void 0 !== Buffer$4) this.buffer = Buffer$4.from(t);
                                else {
                                    if ("undefined" == typeof Uint8Array && !Array.isArray(t)) throw new TypeError("only String, Buffer, Uint8Array or Array accepted");
                                    this.buffer = writeStringToArray(t)
                                }
                            else this.buffer = t;
                            this.position = t.length
                        }
                    }
                    return _createClass$a(e, [{
                        key: "put",
                        value: function(t) {
                            if (null != t.length && "number" != typeof t && 1 !== t.length) throw new TypeError("only accepts single character String, Uint8Array or Array");
                            if ("number" != typeof t && t < 0 || t > 255) throw new TypeError("only accepts number in a valid unsigned byte range 0-255");
                            var n = null;
                            if (n = "string" == typeof t ? t.charCodeAt(0) : null != t.length ? t[0] : t, this.buffer.length > this.position) this.buffer[this.position++] = n;
                            else if (void 0 !== Buffer$4 && Buffer$4.isBuffer(this.buffer)) {
                                var r = Buffer$4.alloc(e.BUFFER_SIZE + this.buffer.length);
                                this.buffer.copy(r, 0, 0, this.buffer.length), this.buffer = r, this.buffer[this.position++] = n
                            } else {
                                var i = null;
                                i = isUint8Array(this.buffer) ? new Uint8Array(new ArrayBuffer(e.BUFFER_SIZE + this.buffer.length)) : new Array(e.BUFFER_SIZE + this.buffer.length);
                                for (var o = 0; o < this.buffer.length; o++) i[o] = this.buffer[o];
                                this.buffer = i, this.buffer[this.position++] = n
                            }
                        }
                    }, {
                        key: "write",
                        value: function(e, t) {
                            if (t = "number" == typeof t ? t : this.position, this.buffer.length < t + e.length) {
                                var n = null;
                                if (void 0 !== Buffer$4 && Buffer$4.isBuffer(this.buffer)) n = Buffer$4.alloc(this.buffer.length + e.length), this.buffer.copy(n, 0, 0, this.buffer.length);
                                else if (isUint8Array(this.buffer)) { n = new Uint8Array(new ArrayBuffer(this.buffer.length + e.length)); for (var r = 0; r < this.position; r++) n[r] = this.buffer[r] }
                                this.buffer = n
                            }
                            if (void 0 !== Buffer$4 && Buffer$4.isBuffer(e) && Buffer$4.isBuffer(this.buffer)) e.copy(this.buffer, t, 0, e.length), this.position = t + e.length > this.position ? t + e.length : this.position;
                            else if (void 0 !== Buffer$4 && "string" == typeof e && Buffer$4.isBuffer(this.buffer)) this.buffer.write(e, t, "binary"), this.position = t + e.length > this.position ? t + e.length : this.position;
                            else if (isUint8Array(e) || Array.isArray(e) && "string" != typeof e) {
                                for (var i = 0; i < e.length; i++) this.buffer[t++] = e[i];
                                this.position = t > this.position ? t : this.position
                            } else if ("string" == typeof e) {
                                for (var o = 0; o < e.length; o++) this.buffer[t++] = e.charCodeAt(o);
                                this.position = t > this.position ? t : this.position
                            }
                        }
                    }, { key: "read", value: function(e, t) { if (t = t && t > 0 ? t : this.position, this.buffer.slice) return this.buffer.slice(e, e + t); for (var n = "undefined" != typeof Uint8Array ? new Uint8Array(new ArrayBuffer(t)) : new Array(t), r = 0; r < t; r++) n[r] = this.buffer[e++]; return n } }, { key: "value", value: function(e) { if ((e = null != e && e) && void 0 !== Buffer$4 && Buffer$4.isBuffer(this.buffer) && this.buffer.length === this.position) return this.buffer; if (void 0 !== Buffer$4 && Buffer$4.isBuffer(this.buffer)) return e ? this.buffer.slice(0, this.position) : this.buffer.toString("binary", 0, this.position); if (e) { if (null != this.buffer.slice) return this.buffer.slice(0, this.position); for (var t = isUint8Array(this.buffer) ? new Uint8Array(new ArrayBuffer(this.position)) : new Array(this.position), n = 0; n < this.position; n++) t[n] = this.buffer[n]; return t } return convertArraytoUtf8BinaryString(this.buffer, 0, this.position) } }, { key: "length", value: function() { return this.position } }, { key: "toJSON", value: function() { return null != this.buffer ? this.buffer.toString("base64") : "" } }, { key: "toString", value: function(e) { return null != this.buffer ? this.buffer.slice(0, this.position).toString(e) : "" } }, {
                        key: "toExtendedJSON",
                        value: function(e) {
                            e = e || {};
                            var t = Buffer$4.isBuffer(this.buffer) ? this.buffer.toString("base64") : Buffer$4.from(this.buffer).toString("base64"),
                                n = Number(this.sub_type).toString(16);
                            return e.legacy ? { $binary: t, $type: 1 === n.length ? "0" + n : n } : { $binary: { base64: t, subType: 1 === n.length ? "0" + n : n } }
                        }
                    }], [{ key: "fromExtendedJSON", value: function(t, n) { var r, i; return (n = n || {}).legacy ? (i = t.$type ? parseInt(t.$type, 16) : 0, r = Buffer$4.from(t.$binary, "base64")) : (i = t.$binary.subType ? parseInt(t.$binary.subType, 16) : 0, r = Buffer$4.from(t.$binary.base64, "base64")), new e(r, i) } }]), e
                }(),
                BSON_BINARY_SUBTYPE_DEFAULT = 0;

            function isUint8Array(e) { return "[object Uint8Array]" === Object.prototype.toString.call(e) }

            function writeStringToArray(e) { for (var t = "undefined" != typeof Uint8Array ? new Uint8Array(new ArrayBuffer(e.length)) : new Array(e.length), n = 0; n < e.length; n++) t[n] = e.charCodeAt(n); return t }

            function convertArraytoUtf8BinaryString(e, t, n) { for (var r = "", i = t; i < n; i++) r += String.fromCharCode(e[i]); return r }
            Binary.BUFFER_SIZE = 256, Binary.SUBTYPE_DEFAULT = 0, Binary.SUBTYPE_FUNCTION = 1, Binary.SUBTYPE_BYTE_ARRAY = 2, Binary.SUBTYPE_UUID_OLD = 3, Binary.SUBTYPE_UUID = 4, Binary.SUBTYPE_MD5 = 5, Binary.SUBTYPE_USER_DEFINED = 128, Object.defineProperty(Binary.prototype, "_bsontype", { value: "Binary" });
            var binary = Binary,
                constants = { BSON_INT32_MAX: 2147483647, BSON_INT32_MIN: -2147483648, BSON_INT64_MAX: Math.pow(2, 63) - 1, BSON_INT64_MIN: -Math.pow(2, 63), JS_INT_MAX: 9007199254740992, JS_INT_MIN: -9007199254740992, BSON_DATA_NUMBER: 1, BSON_DATA_STRING: 2, BSON_DATA_OBJECT: 3, BSON_DATA_ARRAY: 4, BSON_DATA_BINARY: 5, BSON_DATA_UNDEFINED: 6, BSON_DATA_OID: 7, BSON_DATA_BOOLEAN: 8, BSON_DATA_DATE: 9, BSON_DATA_NULL: 10, BSON_DATA_REGEXP: 11, BSON_DATA_DBPOINTER: 12, BSON_DATA_CODE: 13, BSON_DATA_SYMBOL: 14, BSON_DATA_CODE_W_SCOPE: 15, BSON_DATA_INT: 16, BSON_DATA_TIMESTAMP: 17, BSON_DATA_LONG: 18, BSON_DATA_DECIMAL128: 19, BSON_DATA_MIN_KEY: 255, BSON_DATA_MAX_KEY: 127, BSON_BINARY_SUBTYPE_DEFAULT: 0, BSON_BINARY_SUBTYPE_FUNCTION: 1, BSON_BINARY_SUBTYPE_BYTE_ARRAY: 2, BSON_BINARY_SUBTYPE_UUID: 3, BSON_BINARY_SUBTYPE_MD5: 4, BSON_BINARY_SUBTYPE_USER_DEFINED: 128 };

            function _typeof$2(e) { return (_typeof$2 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(e) { return typeof e } : function(e) { return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e })(e) }
            var keysToCodecs = { $oid: objectid, $binary: binary, $symbol: symbol, $numberInt: int_32, $numberDecimal: decimal128, $numberDouble: double_1, $numberLong: long_1$1, $minKey: min_key, $maxKey: max_key, $regex: regexp, $regularExpression: regexp, $timestamp: timestamp };

            function deserializeValue(e, t, n, r) {
                if ("number" == typeof n) { if (r.relaxed || r.legacy) return n; if (Math.floor(n) === n) { if (n >= BSON_INT32_MIN && n <= BSON_INT32_MAX) return new int_32(n); if (n >= BSON_INT64_MIN && n <= BSON_INT64_MAX) return new long_1$1.fromNumber(n) } return new double_1(n) }
                if (null == n || "object" !== _typeof$2(n)) return n;
                if (n.$undefined) return null;
                for (var i = Object.keys(n).filter(function(e) { return e.startsWith("$") && null != n[e] }), o = 0; o < i.length; o++) { var a = keysToCodecs[i[o]]; if (a) return a.fromExtendedJSON(n, r) }
                if (null != n.$date) {
                    var s = n.$date,
                        u = new Date;
                    return r.legacy ? "number" == typeof s ? u.setTime(s) : "string" == typeof s && u.setTime(Date.parse(s)) : "string" == typeof s ? u.setTime(Date.parse(s)) : long_1$1.isLong(s) ? u.setTime(s.toNumber()) : "number" == typeof s && r.relaxed && u.setTime(s), u
                }
                if (null != n.$code) { var c = Object.assign({}, n); return n.$scope && (c.$scope = deserializeValue(e, null, n.$scope)), code.fromExtendedJSON(n) }
                if (null != n.$ref || null != n.$dbPointer) { var f = n.$ref ? n : n.$dbPointer; if (f instanceof db_ref) return f; var l = !0; if (Object.keys(f).filter(function(e) { return e.startsWith("$") }).forEach(function(e) {-1 === ["$ref", "$id", "$db"].indexOf(e) && (l = !1) }), l) return db_ref.fromExtendedJSON(f) }
                return n
            }

            function parse(e, t) { var n = this; return "boolean" == typeof(t = Object.assign({}, { relaxed: !0, legacy: !1 }, t)).relaxed && (t.strict = !t.relaxed), "boolean" == typeof t.strict && (t.relaxed = !t.strict), JSON.parse(e, function(e, r) { return deserializeValue(n, e, r, t) }) }
            var BSON_INT32_MAX = 2147483647,
                BSON_INT32_MIN = -2147483648,
                BSON_INT64_MAX = 0x8000000000000000,
                BSON_INT64_MIN = -0x8000000000000000;

            function stringify(e, t, n, r) { null != n && "object" === _typeof$2(n) && (r = n, n = 0), null == t || "object" !== _typeof$2(t) || Array.isArray(t) || (r = t, t = null, n = 0), r = Object.assign({}, { relaxed: !0, legacy: !1 }, r); var i = Array.isArray(e) ? serializeArray(e, r) : serializeDocument(e, r); return JSON.stringify(i, t, n) }

            function serialize(e, t) { return t = t || {}, JSON.parse(stringify(e, t)) }

            function deserialize(e, t) { return t = t || {}, parse(JSON.stringify(e), t) }

            function serializeArray(e, t) { return e.map(function(e) { return serializeValue(e, t) }) }

            function getISOString(e) { var t = e.toISOString(); return 0 !== e.getUTCMilliseconds() ? t : t.slice(0, -5) + "Z" }

            function serializeValue(e, t) {
                if (Array.isArray(e)) return serializeArray(e, t);
                if (void 0 === e) return null;
                if (e instanceof Date) {
                    var n = e.getTime(),
                        r = n > -1 && n < 2534023188e5;
                    return t.legacy ? t.relaxed && r ? { $date: e.getTime() } : { $date: getISOString(e) } : t.relaxed && r ? { $date: getISOString(e) } : { $date: { $numberLong: e.getTime().toString() } }
                }
                if ("number" == typeof e && !t.relaxed) { if (Math.floor(e) === e) { var i = e >= BSON_INT64_MIN && e <= BSON_INT64_MAX; if (e >= BSON_INT32_MIN && e <= BSON_INT32_MAX) return { $numberInt: e.toString() }; if (i) return { $numberLong: e.toString() } } return { $numberDouble: e.toString() } }
                if (e instanceof RegExp) { var o = e.flags; return void 0 === o && (o = e.toString().match(/[gimuy]*$/)[0]), new regexp(e.source, o).toExtendedJSON(t) }
                return null != e && "object" === _typeof$2(e) ? serializeDocument(e, t) : e
            }
            var BSON_TYPE_MAPPINGS = { Binary: function(e) { return new binary(e.value(), e.subtype) }, Code: function(e) { return new code(e.code, e.scope) }, DBRef: function(e) { return new db_ref(e.collection || e.namespace, e.oid, e.db, e.fields) }, Decimal128: function(e) { return new decimal128(e.bytes) }, Double: function(e) { return new double_1(e.value) }, Int32: function(e) { return new int_32(e.value) }, Long: function(e) { return long_1$1.fromBits(null != e.low ? e.low : e.low_, null != e.low ? e.high : e.high_, null != e.low ? e.unsigned : e.unsigned_) }, MaxKey: function() { return new max_key }, MinKey: function() { return new min_key }, ObjectID: function(e) { return new objectid(e) }, ObjectId: function(e) { return new objectid(e) }, BSONRegExp: function(e) { return new regexp(e.pattern, e.options) }, Symbol: function(e) { return new symbol(e.value) }, Timestamp: function(e) { return timestamp.fromBits(e.low, e.high) } };

            function serializeDocument(e, t) {
                if (null == e || "object" !== _typeof$2(e)) throw new Error("not an object instance");
                var n = e._bsontype;
                if (void 0 === n) { var r = {}; for (var i in e) r[i] = serializeValue(e[i], t); return r }
                if ("string" == typeof n) {
                    var o = e;
                    if ("function" != typeof o.toExtendedJSON) {
                        var a = BSON_TYPE_MAPPINGS[n];
                        if (!a) throw new TypeError("Unrecognized or invalid _bsontype: " + n);
                        o = a(o)
                    }
                    return "Code" === n && o.scope ? o = new code(o.code, serializeValue(o.scope, t)) : "DBRef" === n && o.oid && (o = new db_ref(o.collection, serializeValue(o.oid, t), o.db, o.fields)), o.toExtendedJSON(t)
                }
                throw new Error("_bsontype must be a string, but was: " + _typeof$2(n))
            }
            var extended_json = { parse: parse, deserialize: deserialize, serialize: serialize, stringify: stringify },
                FIRST_BIT = 128,
                FIRST_TWO_BITS = 192,
                FIRST_THREE_BITS = 224,
                FIRST_FOUR_BITS = 240,
                FIRST_FIVE_BITS = 248,
                TWO_BIT_CHAR = 192,
                THREE_BIT_CHAR = 224,
                FOUR_BIT_CHAR = 240,
                CONTINUING_CHAR = 128;

            function validateUtf8(e, t, n) {
                for (var r = 0, i = t; i < n; i += 1) {
                    var o = e[i];
                    if (r) {
                        if ((o & FIRST_TWO_BITS) !== CONTINUING_CHAR) return !1;
                        r -= 1
                    } else if (o & FIRST_BIT)
                        if ((o & FIRST_THREE_BITS) === TWO_BIT_CHAR) r = 1;
                        else if ((o & FIRST_FOUR_BITS) === THREE_BIT_CHAR) r = 2;
                    else {
                        if ((o & FIRST_FIVE_BITS) !== FOUR_BIT_CHAR) return !1;
                        r = 3
                    }
                }
                return !r
            }
            var validateUtf8_1 = validateUtf8,
                validate_utf8 = { validateUtf8: validateUtf8_1 },
                Buffer$5 = bufferEs6.Buffer,
                validateUtf8$1 = validate_utf8.validateUtf8,
                JS_INT_MAX_LONG = long_1$1.fromNumber(constants.JS_INT_MAX),
                JS_INT_MIN_LONG = long_1$1.fromNumber(constants.JS_INT_MIN),
                functionCache = {};

            function deserialize$1(e, t, n) {
                var r = (t = null == t ? {} : t) && t.index ? t.index : 0,
                    i = e[r] | e[r + 1] << 8 | e[r + 2] << 16 | e[r + 3] << 24;
                if (i < 5) throw new Error("bson size must be >= 5, is ".concat(i));
                if (t.allowObjectSmallerThanBufferSize && e.length < i) throw new Error("buffer length ".concat(e.length, " must be >= bson size ").concat(i));
                if (!t.allowObjectSmallerThanBufferSize && e.length !== i) throw new Error("buffer length ".concat(e.length, " must === bson size ").concat(i));
                if (i + r > e.length) throw new Error("(bson size ".concat(i, " + options.index ").concat(r, " must be <= buffer length ").concat(Buffer$5.byteLength(e), ")"));
                if (0 !== e[r + i - 1]) throw new Error("One object, sized correctly, with a spot for an EOO, but the EOO isn't 0x00");
                return deserializeObject(e, r, t, n)
            }

            function deserializeObject(e, t, n, r) {
                var i = null != n.evalFunctions && n.evalFunctions,
                    o = null != n.cacheFunctions && n.cacheFunctions,
                    a = null != n.cacheFunctionsCrc32 && n.cacheFunctionsCrc32;
                if (!a) var s = null;
                var u = null == n.fieldsAsRaw ? null : n.fieldsAsRaw,
                    c = null != n.raw && n.raw,
                    f = "boolean" == typeof n.bsonRegExp && n.bsonRegExp,
                    l = null != n.promoteBuffers && n.promoteBuffers,
                    d = null == n.promoteLongs || n.promoteLongs,
                    h = null == n.promoteValues || n.promoteValues,
                    p = t;
                if (e.length < 5) throw new Error("corrupt bson message < 5 bytes long");
                var _ = e[t++] | e[t++] << 8 | e[t++] << 16 | e[t++] << 24;
                if (_ < 5 || _ > e.length) throw new Error("corrupt bson message");
                for (var b = r ? [] : {}, g = 0;;) {
                    var E = e[t++];
                    if (0 === E) break;
                    for (var O = t; 0 !== e[O] && O < e.length;) O++;
                    if (O >= Buffer$5.byteLength(e)) throw new Error("Bad BSON Document: illegal CString");
                    var y = r ? g++ : e.toString("utf8", t, O);
                    if (t = O + 1, E === constants.BSON_DATA_STRING) {
                        var m = e[t++] | e[t++] << 8 | e[t++] << 16 | e[t++] << 24;
                        if (m <= 0 || m > e.length - t || 0 !== e[t + m - 1]) throw new Error("bad string length in bson");
                        if (!validateUtf8$1(e, t, t + m - 1)) throw new Error("Invalid UTF-8 string in BSON document");
                        var T = e.toString("utf8", t, t + m - 1);
                        b[y] = T, t += m
                    } else if (E === constants.BSON_DATA_OID) {
                        var v = Buffer$5.alloc(12);
                        e.copy(v, 0, t, t + 12), b[y] = new objectid(v), t += 12
                    } else if (E === constants.BSON_DATA_INT && !1 === h) b[y] = new int_32(e[t++] | e[t++] << 8 | e[t++] << 16 | e[t++] << 24);
                    else if (E === constants.BSON_DATA_INT) b[y] = e[t++] | e[t++] << 8 | e[t++] << 16 | e[t++] << 24;
                    else if (E === constants.BSON_DATA_NUMBER && !1 === h) b[y] = new double_1(e.readDoubleLE(t)), t += 8;
                    else if (E === constants.BSON_DATA_NUMBER) b[y] = e.readDoubleLE(t), t += 8;
                    else if (E === constants.BSON_DATA_DATE) {
                        var S = e[t++] | e[t++] << 8 | e[t++] << 16 | e[t++] << 24,
                            N = e[t++] | e[t++] << 8 | e[t++] << 16 | e[t++] << 24;
                        b[y] = new Date(new long_1$1(S, N).toNumber())
                    } else if (E === constants.BSON_DATA_BOOLEAN) {
                        if (0 !== e[t] && 1 !== e[t]) throw new Error("illegal boolean type value");
                        b[y] = 1 === e[t++]
                    } else if (E === constants.BSON_DATA_OBJECT) {
                        var I = t,
                            A = e[t] | e[t + 1] << 8 | e[t + 2] << 16 | e[t + 3] << 24;
                        if (A <= 0 || A > e.length - t) throw new Error("bad embedded document length in bson");
                        b[y] = c ? e.slice(t, t + A) : deserializeObject(e, I, n, !1), t += A
                    } else if (E === constants.BSON_DATA_ARRAY) {
                        var w = t,
                            R = e[t] | e[t + 1] << 8 | e[t + 2] << 16 | e[t + 3] << 24,
                            C = n,
                            D = t + R;
                        if (u && u[y]) {
                            for (var B in C = {}, n) C[B] = n[B];
                            C.raw = !0
                        }
                        if (b[y] = deserializeObject(e, w, C, !0), 0 !== e[(t += R) - 1]) throw new Error("invalid array terminator byte");
                        if (t !== D) throw new Error("corrupted array bson")
                    } else if (E === constants.BSON_DATA_UNDEFINED) b[y] = void 0;
                    else if (E === constants.BSON_DATA_NULL) b[y] = null;
                    else if (E === constants.BSON_DATA_LONG) {
                        var L = e[t++] | e[t++] << 8 | e[t++] << 16 | e[t++] << 24,
                            j = e[t++] | e[t++] << 8 | e[t++] << 16 | e[t++] << 24,
                            P = new long_1$1(L, j);
                        b[y] = d && !0 === h && P.lessThanOrEqual(JS_INT_MAX_LONG) && P.greaterThanOrEqual(JS_INT_MIN_LONG) ? P.toNumber() : P
                    } else if (E === constants.BSON_DATA_DECIMAL128) {
                        var M = Buffer$5.alloc(16);
                        e.copy(M, 0, t, t + 16), t += 16;
                        var U = new decimal128(M);
                        b[y] = U.toObject ? U.toObject() : U
                    } else if (E === constants.BSON_DATA_BINARY) {
                        var x = e[t++] | e[t++] << 8 | e[t++] << 16 | e[t++] << 24,
                            $ = x,
                            k = e[t++];
                        if (x < 0) throw new Error("Negative binary type element size found");
                        if (x > Buffer$5.byteLength(e)) throw new Error("Binary type size larger than document size");
                        if (null != e.slice) {
                            if (k === binary.SUBTYPE_BYTE_ARRAY) { if ((x = e[t++] | e[t++] << 8 | e[t++] << 16 | e[t++] << 24) < 0) throw new Error("Negative binary type element size found for subtype 0x02"); if (x > $ - 4) throw new Error("Binary type with subtype 0x02 contains to long binary size"); if (x < $ - 4) throw new Error("Binary type with subtype 0x02 contains to short binary size") }
                            b[y] = l && h ? e.slice(t, t + x) : new binary(e.slice(t, t + x), k)
                        } else {
                            var F = "undefined" != typeof Uint8Array ? new Uint8Array(new ArrayBuffer(x)) : new Array(x);
                            if (k === binary.SUBTYPE_BYTE_ARRAY) { if ((x = e[t++] | e[t++] << 8 | e[t++] << 16 | e[t++] << 24) < 0) throw new Error("Negative binary type element size found for subtype 0x02"); if (x > $ - 4) throw new Error("Binary type with subtype 0x02 contains to long binary size"); if (x < $ - 4) throw new Error("Binary type with subtype 0x02 contains to short binary size") }
                            for (O = 0; O < x; O++) F[O] = e[t + O];
                            b[y] = l && h ? F : new binary(F, k)
                        }
                        t += x
                    } else if (E === constants.BSON_DATA_REGEXP && !1 === f) {
                        for (O = t; 0 !== e[O] && O < e.length;) O++;
                        if (O >= e.length) throw new Error("Bad BSON Document: illegal CString");
                        var W = e.toString("utf8", t, O);
                        for (O = t = O + 1; 0 !== e[O] && O < e.length;) O++;
                        if (O >= e.length) throw new Error("Bad BSON Document: illegal CString");
                        var q = e.toString("utf8", t, O);
                        t = O + 1;
                        var z = new Array(q.length);
                        for (O = 0; O < q.length; O++) switch (q[O]) {
                            case "m":
                                z[O] = "m";
                                break;
                            case "s":
                                z[O] = "g";
                                break;
                            case "i":
                                z[O] = "i"
                        }
                        b[y] = new RegExp(W, z.join(""))
                    } else if (E === constants.BSON_DATA_REGEXP && !0 === f) {
                        for (O = t; 0 !== e[O] && O < e.length;) O++;
                        if (O >= e.length) throw new Error("Bad BSON Document: illegal CString");
                        var Y = e.toString("utf8", t, O);
                        for (O = t = O + 1; 0 !== e[O] && O < e.length;) O++;
                        if (O >= e.length) throw new Error("Bad BSON Document: illegal CString");
                        var G = e.toString("utf8", t, O);
                        t = O + 1, b[y] = new regexp(Y, G)
                    } else if (E === constants.BSON_DATA_SYMBOL) {
                        var H = e[t++] | e[t++] << 8 | e[t++] << 16 | e[t++] << 24;
                        if (H <= 0 || H > e.length - t || 0 !== e[t + H - 1]) throw new Error("bad string length in bson");
                        b[y] = e.toString("utf8", t, t + H - 1), t += H
                    } else if (E === constants.BSON_DATA_TIMESTAMP) {
                        var K = e[t++] | e[t++] << 8 | e[t++] << 16 | e[t++] << 24,
                            V = e[t++] | e[t++] << 8 | e[t++] << 16 | e[t++] << 24;
                        b[y] = new timestamp(K, V)
                    } else if (E === constants.BSON_DATA_MIN_KEY) b[y] = new min_key;
                    else if (E === constants.BSON_DATA_MAX_KEY) b[y] = new max_key;
                    else if (E === constants.BSON_DATA_CODE) {
                        var X = e[t++] | e[t++] << 8 | e[t++] << 16 | e[t++] << 24;
                        if (X <= 0 || X > e.length - t || 0 !== e[t + X - 1]) throw new Error("bad string length in bson");
                        var J = e.toString("utf8", t, t + X - 1);
                        if (i)
                            if (o) {
                                var Q = a ? s(J) : J;
                                b[y] = isolateEvalWithHash(functionCache, Q, J, b)
                            } else b[y] = isolateEval(J);
                        else b[y] = new code(J);
                        t += X
                    } else if (E === constants.BSON_DATA_CODE_W_SCOPE) {
                        var Z = e[t++] | e[t++] << 8 | e[t++] << 16 | e[t++] << 24;
                        if (Z < 13) throw new Error("code_w_scope total size shorter minimum expected length");
                        var ee = e[t++] | e[t++] << 8 | e[t++] << 16 | e[t++] << 24;
                        if (ee <= 0 || ee > e.length - t || 0 !== e[t + ee - 1]) throw new Error("bad string length in bson");
                        var te = e.toString("utf8", t, t + ee - 1),
                            ne = t += ee,
                            re = e[t] | e[t + 1] << 8 | e[t + 2] << 16 | e[t + 3] << 24,
                            ie = deserializeObject(e, ne, n, !1);
                        if (t += re, Z < 8 + re + ee) throw new Error("code_w_scope total size is to short, truncating scope");
                        if (Z > 8 + re + ee) throw new Error("code_w_scope total size is to long, clips outer document");
                        if (i) {
                            if (o) {
                                var oe = a ? s(te) : te;
                                b[y] = isolateEvalWithHash(functionCache, oe, te, b)
                            } else b[y] = isolateEval(te);
                            b[y].scope = ie
                        } else b[y] = new code(te, ie)
                    } else {
                        if (E !== constants.BSON_DATA_DBPOINTER) throw new Error("Detected unknown BSON type " + E.toString(16) + ' for fieldname "' + y + '", are you using the latest BSON parser?');
                        var ae = e[t++] | e[t++] << 8 | e[t++] << 16 | e[t++] << 24;
                        if (ae <= 0 || ae > e.length - t || 0 !== e[t + ae - 1]) throw new Error("bad string length in bson");
                        if (!validateUtf8$1(e, t, t + ae - 1)) throw new Error("Invalid UTF-8 string in BSON document");
                        var se = e.toString("utf8", t, t + ae - 1);
                        t += ae;
                        var ue = Buffer$5.alloc(12);
                        e.copy(ue, 0, t, t + 12);
                        var ce = new objectid(ue);
                        t += 12, b[y] = new db_ref(se, ce)
                    }
                }
                if (_ !== t - p) { if (r) throw new Error("corrupt array bson"); throw new Error("corrupt object bson") }
                var fe = !0;
                if (Object.keys(b).filter(function(e) { return e.startsWith("$") }).forEach(function(e) {-1 === ["$ref", "$id", "$db"].indexOf(e) && (fe = !1) }), !fe) return b;
                if (null != b.$id && null != b.$ref) { var le = Object.assign({}, b); return delete le.$ref, delete le.$id, delete le.$db, new db_ref(b.$ref, b.$id, b.$db || null, le) }
                return b
            }

            function isolateEvalWithHash(functionCache, hash, functionString, object) { var value = null; return null == functionCache[hash] && (eval("value = " + functionString), functionCache[hash] = value), functionCache[hash].bind(object) }

            function isolateEval(functionString) { var value = null; return eval("value = " + functionString), value }
            var deserializer = deserialize$1;

            function readIEEE754(e, t, n, r, i) {
                var o, a, s = "big" === n,
                    u = 8 * i - r - 1,
                    c = (1 << u) - 1,
                    f = c >> 1,
                    l = -7,
                    d = s ? 0 : i - 1,
                    h = s ? 1 : -1,
                    p = e[t + d];
                for (d += h, o = p & (1 << -l) - 1, p >>= -l, l += u; l > 0; o = 256 * o + e[t + d], d += h, l -= 8);
                for (a = o & (1 << -l) - 1, o >>= -l, l += r; l > 0; a = 256 * a + e[t + d], d += h, l -= 8);
                if (0 === o) o = 1 - f;
                else {
                    if (o === c) return a ? NaN : 1 / 0 * (p ? -1 : 1);
                    a += Math.pow(2, r), o -= f
                }
                return (p ? -1 : 1) * a * Math.pow(2, o - r)
            }

            function writeIEEE754(e, t, n, r, i, o) {
                var a, s, u, c = "big" === r,
                    f = 8 * o - i - 1,
                    l = (1 << f) - 1,
                    d = l >> 1,
                    h = 23 === i ? Math.pow(2, -24) - Math.pow(2, -77) : 0,
                    p = c ? o - 1 : 0,
                    _ = c ? -1 : 1,
                    b = t < 0 || 0 === t && 1 / t < 0 ? 1 : 0;
                for (t = Math.abs(t), isNaN(t) || t === 1 / 0 ? (s = isNaN(t) ? 1 : 0, a = l) : (a = Math.floor(Math.log(t) / Math.LN2), t * (u = Math.pow(2, -a)) < 1 && (a--, u *= 2), (t += a + d >= 1 ? h / u : h * Math.pow(2, 1 - d)) * u >= 2 && (a++, u /= 2), a + d >= l ? (s = 0, a = l) : a + d >= 1 ? (s = (t * u - 1) * Math.pow(2, i), a += d) : (s = t * Math.pow(2, d - 1) * Math.pow(2, i), a = 0)), isNaN(t) && (s = 0); i >= 8;) e[n + p] = 255 & s, p += _, s /= 256, i -= 8;
                for (a = a << i | s, isNaN(t) && (a += 8), f += i; f > 0;) e[n + p] = 255 & a, p += _, a /= 256, f -= 8;
                e[n + p - _] |= 128 * b
            }
            var float_parser = { readIEEE754: readIEEE754, writeIEEE754: writeIEEE754 };

            function _typeof$3(e) { return (_typeof$3 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(e) { return typeof e } : function(e) { return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e })(e) }
            var Buffer$6 = bufferEs6.Buffer,
                writeIEEE754$1 = float_parser.writeIEEE754,
                normalizedFunctionString$1 = utils.normalizedFunctionString,
                regexp$1 = /\x00/,
                ignoreKeys = new Set(["$db", "$ref", "$id", "$clusterTime"]),
                isDate$1 = function(e) { return "object" === _typeof$3(e) && "[object Date]" === Object.prototype.toString.call(e) },
                isRegExp$1 = function(e) { return "[object RegExp]" === Object.prototype.toString.call(e) };

            function serializeString(e, t, n, r, i) { e[r++] = constants.BSON_DATA_STRING, e[(r = r + (i ? e.write(t, r, "ascii") : e.write(t, r, "utf8")) + 1) - 1] = 0; var o = e.write(n, r + 4, "utf8"); return e[r + 3] = o + 1 >> 24 & 255, e[r + 2] = o + 1 >> 16 & 255, e[r + 1] = o + 1 >> 8 & 255, e[r] = o + 1 & 255, r = r + 4 + o, e[r++] = 0, r }

            function serializeNumber(e, t, n, r, i) {
                if (Math.floor(n) === n && n >= constants.JS_INT_MIN && n <= constants.JS_INT_MAX)
                    if (n >= constants.BSON_INT32_MIN && n <= constants.BSON_INT32_MAX) e[r++] = constants.BSON_DATA_INT, r += i ? e.write(t, r, "ascii") : e.write(t, r, "utf8"), e[r++] = 0, e[r++] = 255 & n, e[r++] = n >> 8 & 255, e[r++] = n >> 16 & 255, e[r++] = n >> 24 & 255;
                    else if (n >= constants.JS_INT_MIN && n <= constants.JS_INT_MAX) { e[r++] = constants.BSON_DATA_NUMBER, r += i ? e.write(t, r, "ascii") : e.write(t, r, "utf8"), e[r++] = 0, writeIEEE754$1(e, n, r, "little", 52, 8), r += 8 } else {
                    e[r++] = constants.BSON_DATA_LONG, r += i ? e.write(t, r, "ascii") : e.write(t, r, "utf8"), e[r++] = 0;
                    var o = long_1$1.fromNumber(n),
                        a = o.getLowBits(),
                        s = o.getHighBits();
                    e[r++] = 255 & a, e[r++] = a >> 8 & 255, e[r++] = a >> 16 & 255, e[r++] = a >> 24 & 255, e[r++] = 255 & s, e[r++] = s >> 8 & 255, e[r++] = s >> 16 & 255, e[r++] = s >> 24 & 255
                } else e[r++] = constants.BSON_DATA_NUMBER, r += i ? e.write(t, r, "ascii") : e.write(t, r, "utf8"), e[r++] = 0, writeIEEE754$1(e, n, r, "little", 52, 8), r += 8;
                return r
            }

            function serializeNull(e, t, n, r, i) { return e[r++] = constants.BSON_DATA_NULL, r += i ? e.write(t, r, "ascii") : e.write(t, r, "utf8"), e[r++] = 0, r }

            function serializeBoolean(e, t, n, r, i) { return e[r++] = constants.BSON_DATA_BOOLEAN, r += i ? e.write(t, r, "ascii") : e.write(t, r, "utf8"), e[r++] = 0, e[r++] = n ? 1 : 0, r }

            function serializeDate(e, t, n, r, i) {
                e[r++] = constants.BSON_DATA_DATE, r += i ? e.write(t, r, "ascii") : e.write(t, r, "utf8"), e[r++] = 0;
                var o = long_1$1.fromNumber(n.getTime()),
                    a = o.getLowBits(),
                    s = o.getHighBits();
                return e[r++] = 255 & a, e[r++] = a >> 8 & 255, e[r++] = a >> 16 & 255, e[r++] = a >> 24 & 255, e[r++] = 255 & s, e[r++] = s >> 8 & 255, e[r++] = s >> 16 & 255, e[r++] = s >> 24 & 255, r
            }

            function serializeRegExp(e, t, n, r, i) { if (e[r++] = constants.BSON_DATA_REGEXP, r += i ? e.write(t, r, "ascii") : e.write(t, r, "utf8"), e[r++] = 0, n.source && null != n.source.match(regexp$1)) throw Error("value " + n.source + " must not contain null bytes"); return r += e.write(n.source, r, "utf8"), e[r++] = 0, n.ignoreCase && (e[r++] = 105), n.global && (e[r++] = 115), n.multiline && (e[r++] = 109), e[r++] = 0, r }

            function serializeBSONRegExp(e, t, n, r, i) { if (e[r++] = constants.BSON_DATA_REGEXP, r += i ? e.write(t, r, "ascii") : e.write(t, r, "utf8"), e[r++] = 0, null != n.pattern.match(regexp$1)) throw Error("pattern " + n.pattern + " must not contain null bytes"); return r += e.write(n.pattern, r, "utf8"), e[r++] = 0, r += e.write(n.options.split("").sort().join(""), r, "utf8"), e[r++] = 0, r }

            function serializeMinMax(e, t, n, r, i) { return null === n ? e[r++] = constants.BSON_DATA_NULL : "MinKey" === n._bsontype ? e[r++] = constants.BSON_DATA_MIN_KEY : e[r++] = constants.BSON_DATA_MAX_KEY, r += i ? e.write(t, r, "ascii") : e.write(t, r, "utf8"), e[r++] = 0, r }

            function serializeObjectId(e, t, n, r, i) {
                if (e[r++] = constants.BSON_DATA_OID, r += i ? e.write(t, r, "ascii") : e.write(t, r, "utf8"), e[r++] = 0, "string" == typeof n.id) e.write(n.id, r, "binary");
                else {
                    if (!n.id || !n.id.copy) throw new TypeError("object [" + JSON.stringify(n) + "] is not a valid ObjectId");
                    n.id.copy(e, r, 0, 12)
                }
                return r + 12
            }

            function serializeBuffer(e, t, n, r, i) { e[r++] = constants.BSON_DATA_BINARY, r += i ? e.write(t, r, "ascii") : e.write(t, r, "utf8"), e[r++] = 0; var o = n.length; return e[r++] = 255 & o, e[r++] = o >> 8 & 255, e[r++] = o >> 16 & 255, e[r++] = o >> 24 & 255, e[r++] = constants.BSON_BINARY_SUBTYPE_DEFAULT, n.copy(e, r, 0, o), r += o }

            function serializeObject(e, t, n, r, i, o, a, s, u, c) {
                for (var f = 0; f < c.length; f++)
                    if (c[f] === n) throw new Error("cyclic dependency detected");
                c.push(n), e[r++] = Array.isArray(n) ? constants.BSON_DATA_ARRAY : constants.BSON_DATA_OBJECT, r += u ? e.write(t, r, "ascii") : e.write(t, r, "utf8"), e[r++] = 0;
                var l = serializeInto(e, n, i, r, o + 1, a, s, c);
                return c.pop(), l
            }

            function serializeDecimal128(e, t, n, r, i) { return e[r++] = constants.BSON_DATA_DECIMAL128, r += i ? e.write(t, r, "ascii") : e.write(t, r, "utf8"), e[r++] = 0, n.bytes.copy(e, r, 0, 16), r + 16 }

            function serializeLong(e, t, n, r, i) {
                e[r++] = "Long" === n._bsontype ? constants.BSON_DATA_LONG : constants.BSON_DATA_TIMESTAMP, r += i ? e.write(t, r, "ascii") : e.write(t, r, "utf8"), e[r++] = 0;
                var o = n.getLowBits(),
                    a = n.getHighBits();
                return e[r++] = 255 & o, e[r++] = o >> 8 & 255, e[r++] = o >> 16 & 255, e[r++] = o >> 24 & 255, e[r++] = 255 & a, e[r++] = a >> 8 & 255, e[r++] = a >> 16 & 255, e[r++] = a >> 24 & 255, r
            }

            function serializeInt32(e, t, n, r, i) { return e[r++] = constants.BSON_DATA_INT, r += i ? e.write(t, r, "ascii") : e.write(t, r, "utf8"), e[r++] = 0, e[r++] = 255 & n, e[r++] = n >> 8 & 255, e[r++] = n >> 16 & 255, e[r++] = n >> 24 & 255, r }

            function serializeDouble(e, t, n, r, i) { return e[r++] = constants.BSON_DATA_NUMBER, r += i ? e.write(t, r, "ascii") : e.write(t, r, "utf8"), e[r++] = 0, writeIEEE754$1(e, n.value, r, "little", 52, 8), r += 8 }

            function serializeFunction(e, t, n, r, i, o, a) {
                e[r++] = constants.BSON_DATA_CODE, r += a ? e.write(t, r, "ascii") : e.write(t, r, "utf8"), e[r++] = 0;
                var s = normalizedFunctionString$1(n),
                    u = e.write(s, r + 4, "utf8") + 1;
                return e[r] = 255 & u, e[r + 1] = u >> 8 & 255, e[r + 2] = u >> 16 & 255, e[r + 3] = u >> 24 & 255, r = r + 4 + u - 1, e[r++] = 0, r
            }

            function serializeCode(e, t, n, r, i, o, a, s, u) {
                if (n.scope && "object" === _typeof$3(n.scope)) {
                    e[r++] = constants.BSON_DATA_CODE_W_SCOPE, r += u ? e.write(t, r, "ascii") : e.write(t, r, "utf8"), e[r++] = 0;
                    var c = r,
                        f = "string" == typeof n.code ? n.code : n.code.toString();
                    r += 4;
                    var l = e.write(f, r + 4, "utf8") + 1;
                    e[r] = 255 & l, e[r + 1] = l >> 8 & 255, e[r + 2] = l >> 16 & 255, e[r + 3] = l >> 24 & 255, e[r + 4 + l - 1] = 0, r = r + l + 4;
                    var d = serializeInto(e, n.scope, i, r, o + 1, a, s);
                    r = d - 1;
                    var h = d - c;
                    e[c++] = 255 & h, e[c++] = h >> 8 & 255, e[c++] = h >> 16 & 255, e[c++] = h >> 24 & 255, e[r++] = 0
                } else {
                    e[r++] = constants.BSON_DATA_CODE, r += u ? e.write(t, r, "ascii") : e.write(t, r, "utf8"), e[r++] = 0;
                    var p = n.code.toString(),
                        _ = e.write(p, r + 4, "utf8") + 1;
                    e[r] = 255 & _, e[r + 1] = _ >> 8 & 255, e[r + 2] = _ >> 16 & 255, e[r + 3] = _ >> 24 & 255, r = r + 4 + _ - 1, e[r++] = 0
                }
                return r
            }

            function serializeBinary(e, t, n, r, i) {
                e[r++] = constants.BSON_DATA_BINARY, r += i ? e.write(t, r, "ascii") : e.write(t, r, "utf8"), e[r++] = 0;
                var o = n.value(!0),
                    a = n.position;
                return n.sub_type === binary.SUBTYPE_BYTE_ARRAY && (a += 4), e[r++] = 255 & a, e[r++] = a >> 8 & 255, e[r++] = a >> 16 & 255, e[r++] = a >> 24 & 255, e[r++] = n.sub_type, n.sub_type === binary.SUBTYPE_BYTE_ARRAY && (a -= 4, e[r++] = 255 & a, e[r++] = a >> 8 & 255, e[r++] = a >> 16 & 255, e[r++] = a >> 24 & 255), o.copy(e, r, 0, n.position), r += n.position
            }

            function serializeSymbol(e, t, n, r, i) { e[r++] = constants.BSON_DATA_SYMBOL, r += i ? e.write(t, r, "ascii") : e.write(t, r, "utf8"), e[r++] = 0; var o = e.write(n.value, r + 4, "utf8") + 1; return e[r] = 255 & o, e[r + 1] = o >> 8 & 255, e[r + 2] = o >> 16 & 255, e[r + 3] = o >> 24 & 255, r = r + 4 + o - 1, e[r++] = 0, r }

            function serializeDBRef(e, t, n, r, i, o, a) {
                e[r++] = constants.BSON_DATA_OBJECT, r += a ? e.write(t, r, "ascii") : e.write(t, r, "utf8"), e[r++] = 0;
                var s, u = r,
                    c = { $ref: n.collection || n.namespace, $id: n.oid };
                null != n.db && (c.$db = n.db);
                var f = (s = serializeInto(e, c = Object.assign(c, n.fields), !1, r, i + 1, o)) - u;
                return e[u++] = 255 & f, e[u++] = f >> 8 & 255, e[u++] = f >> 16 & 255, e[u++] = f >> 24 & 255, s
            }

            function serializeInto(e, t, n, r, i, o, a, s) {
                r = r || 0, (s = s || []).push(t);
                var u = r + 4;
                if (Array.isArray(t))
                    for (var c = 0; c < t.length; c++) {
                        var f = "" + c,
                            l = t[c];
                        if (l && l.toBSON) {
                            if ("function" != typeof l.toBSON) throw new TypeError("toBSON is not a function");
                            l = l.toBSON()
                        }
                        var d = _typeof$3(l);
                        if ("string" === d) u = serializeString(e, f, l, u, !0);
                        else if ("number" === d) u = serializeNumber(e, f, l, u, !0);
                        else if ("boolean" === d) u = serializeBoolean(e, f, l, u, !0);
                        else if (l instanceof Date || isDate$1(l)) u = serializeDate(e, f, l, u, !0);
                        else if (void 0 === l) u = serializeNull(e, f, l, u, !0);
                        else if (null === l) u = serializeNull(e, f, l, u, !0);
                        else if ("ObjectId" === l._bsontype || "ObjectID" === l._bsontype) u = serializeObjectId(e, f, l, u, !0);
                        else if (Buffer$6.isBuffer(l)) u = serializeBuffer(e, f, l, u, !0);
                        else if (l instanceof RegExp || isRegExp$1(l)) u = serializeRegExp(e, f, l, u, !0);
                        else if ("object" === d && null == l._bsontype) u = serializeObject(e, f, l, u, n, i, o, a, !0, s);
                        else if ("object" === d && "Decimal128" === l._bsontype) u = serializeDecimal128(e, f, l, u, !0);
                        else if ("Long" === l._bsontype || "Timestamp" === l._bsontype) u = serializeLong(e, f, l, u, !0);
                        else if ("Double" === l._bsontype) u = serializeDouble(e, f, l, u, !0);
                        else if ("function" == typeof l && o) u = serializeFunction(e, f, l, u, n, i, o, !0);
                        else if ("Code" === l._bsontype) u = serializeCode(e, f, l, u, n, i, o, a, !0);
                        else if ("Binary" === l._bsontype) u = serializeBinary(e, f, l, u, !0);
                        else if ("Symbol" === l._bsontype) u = serializeSymbol(e, f, l, u, !0);
                        else if ("DBRef" === l._bsontype) u = serializeDBRef(e, f, l, u, i, o, !0);
                        else if ("BSONRegExp" === l._bsontype) u = serializeBSONRegExp(e, f, l, u, !0);
                        else if ("Int32" === l._bsontype) u = serializeInt32(e, f, l, u, !0);
                        else if ("MinKey" === l._bsontype || "MaxKey" === l._bsontype) u = serializeMinMax(e, f, l, u, !0);
                        else if (void 0 !== l._bsontype) throw new TypeError("Unrecognized or invalid _bsontype: " + l._bsontype)
                    } else if (t instanceof map)
                        for (var h = t.entries(), p = !1; !p;) {
                            var _ = h.next();
                            if (!(p = _.done)) {
                                var b = _.value[0],
                                    g = _.value[1],
                                    E = _typeof$3(g);
                                if ("string" == typeof b && !ignoreKeys.has(b)) { if (null != b.match(regexp$1)) throw Error("key " + b + " must not contain null bytes"); if (n) { if ("$" === b[0]) throw Error("key " + b + " must not start with '$'"); if (~b.indexOf(".")) throw Error("key " + b + " must not contain '.'") } }
                                if ("string" === E) u = serializeString(e, b, g, u);
                                else if ("number" === E) u = serializeNumber(e, b, g, u);
                                else if ("boolean" === E) u = serializeBoolean(e, b, g, u);
                                else if (g instanceof Date || isDate$1(g)) u = serializeDate(e, b, g, u);
                                else if (null === g || void 0 === g && !1 === a) u = serializeNull(e, b, g, u);
                                else if ("ObjectId" === g._bsontype || "ObjectID" === g._bsontype) u = serializeObjectId(e, b, g, u);
                                else if (Buffer$6.isBuffer(g)) u = serializeBuffer(e, b, g, u);
                                else if (g instanceof RegExp || isRegExp$1(g)) u = serializeRegExp(e, b, g, u);
                                else if ("object" === E && null == g._bsontype) u = serializeObject(e, b, g, u, n, i, o, a, !1, s);
                                else if ("object" === E && "Decimal128" === g._bsontype) u = serializeDecimal128(e, b, g, u);
                                else if ("Long" === g._bsontype || "Timestamp" === g._bsontype) u = serializeLong(e, b, g, u);
                                else if ("Double" === g._bsontype) u = serializeDouble(e, b, g, u);
                                else if ("Code" === g._bsontype) u = serializeCode(e, b, g, u, n, i, o, a);
                                else if ("function" == typeof g && o) u = serializeFunction(e, b, g, u, n, i, o);
                                else if ("Binary" === g._bsontype) u = serializeBinary(e, b, g, u);
                                else if ("Symbol" === g._bsontype) u = serializeSymbol(e, b, g, u);
                                else if ("DBRef" === g._bsontype) u = serializeDBRef(e, b, g, u, i, o);
                                else if ("BSONRegExp" === g._bsontype) u = serializeBSONRegExp(e, b, g, u);
                                else if ("Int32" === g._bsontype) u = serializeInt32(e, b, g, u);
                                else if ("MinKey" === g._bsontype || "MaxKey" === g._bsontype) u = serializeMinMax(e, b, g, u);
                                else if (void 0 !== g._bsontype) throw new TypeError("Unrecognized or invalid _bsontype: " + g._bsontype)
                            }
                        } else {
                            if (t.toBSON) { if ("function" != typeof t.toBSON) throw new TypeError("toBSON is not a function"); if (null != (t = t.toBSON()) && "object" !== _typeof$3(t)) throw new TypeError("toBSON function did not return an object") }
                            for (var O in t) {
                                var y = t[O];
                                if (y && y.toBSON) {
                                    if ("function" != typeof y.toBSON) throw new TypeError("toBSON is not a function");
                                    y = y.toBSON()
                                }
                                var m = _typeof$3(y);
                                if ("string" == typeof O && !ignoreKeys.has(O)) { if (null != O.match(regexp$1)) throw Error("key " + O + " must not contain null bytes"); if (n) { if ("$" === O[0]) throw Error("key " + O + " must not start with '$'"); if (~O.indexOf(".")) throw Error("key " + O + " must not contain '.'") } }
                                if ("string" === m) u = serializeString(e, O, y, u);
                                else if ("number" === m) u = serializeNumber(e, O, y, u);
                                else if ("boolean" === m) u = serializeBoolean(e, O, y, u);
                                else if (y instanceof Date || isDate$1(y)) u = serializeDate(e, O, y, u);
                                else if (void 0 === y) !1 === a && (u = serializeNull(e, O, y, u));
                                else if (null === y) u = serializeNull(e, O, y, u);
                                else if ("ObjectId" === y._bsontype || "ObjectID" === y._bsontype) u = serializeObjectId(e, O, y, u);
                                else if (Buffer$6.isBuffer(y)) u = serializeBuffer(e, O, y, u);
                                else if (y instanceof RegExp || isRegExp$1(y)) u = serializeRegExp(e, O, y, u);
                                else if ("object" === m && null == y._bsontype) u = serializeObject(e, O, y, u, n, i, o, a, !1, s);
                                else if ("object" === m && "Decimal128" === y._bsontype) u = serializeDecimal128(e, O, y, u);
                                else if ("Long" === y._bsontype || "Timestamp" === y._bsontype) u = serializeLong(e, O, y, u);
                                else if ("Double" === y._bsontype) u = serializeDouble(e, O, y, u);
                                else if ("Code" === y._bsontype) u = serializeCode(e, O, y, u, n, i, o, a);
                                else if ("function" == typeof y && o) u = serializeFunction(e, O, y, u, n, i, o);
                                else if ("Binary" === y._bsontype) u = serializeBinary(e, O, y, u);
                                else if ("Symbol" === y._bsontype) u = serializeSymbol(e, O, y, u);
                                else if ("DBRef" === y._bsontype) u = serializeDBRef(e, O, y, u, i, o);
                                else if ("BSONRegExp" === y._bsontype) u = serializeBSONRegExp(e, O, y, u);
                                else if ("Int32" === y._bsontype) u = serializeInt32(e, O, y, u);
                                else if ("MinKey" === y._bsontype || "MaxKey" === y._bsontype) u = serializeMinMax(e, O, y, u);
                                else if (void 0 !== y._bsontype) throw new TypeError("Unrecognized or invalid _bsontype: " + y._bsontype)
                            }
                        }
                s.pop(), e[u++] = 0;
                var T = u - r;
                return e[r++] = 255 & T, e[r++] = T >> 8 & 255, e[r++] = T >> 16 & 255, e[r++] = T >> 24 & 255, u
            }
            var serializer = serializeInto;

            function _typeof$4(e) { return (_typeof$4 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(e) { return typeof e } : function(e) { return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e })(e) }
            var Buffer$7 = bufferEs6.Buffer,
                normalizedFunctionString$2 = utils.normalizedFunctionString;

            function isDate$2(e) { return "object" === _typeof$4(e) && "[object Date]" === Object.prototype.toString.call(e) }

            function calculateObjectSize(e, t, n) {
                var r = 5;
                if (Array.isArray(e))
                    for (var i = 0; i < e.length; i++) r += calculateElement(i.toString(), e[i], t, !0, n);
                else
                    for (var o in e.toBSON && (e = e.toBSON()), e) r += calculateElement(o, e[o], t, !1, n);
                return r
            }

            function calculateElement(e, t, n, r, i) {
                switch (t && t.toBSON && (t = t.toBSON()), _typeof$4(t)) {
                    case "string":
                        return 1 + Buffer$7.byteLength(e, "utf8") + 1 + 4 + Buffer$7.byteLength(t, "utf8") + 1;
                    case "number":
                        return Math.floor(t) === t && t >= constants.JS_INT_MIN && t <= constants.JS_INT_MAX && t >= constants.BSON_INT32_MIN && t <= constants.BSON_INT32_MAX ? (null != e ? Buffer$7.byteLength(e, "utf8") + 1 : 0) + 5 : (null != e ? Buffer$7.byteLength(e, "utf8") + 1 : 0) + 9;
                    case "undefined":
                        return r || !i ? (null != e ? Buffer$7.byteLength(e, "utf8") + 1 : 0) + 1 : 0;
                    case "boolean":
                        return (null != e ? Buffer$7.byteLength(e, "utf8") + 1 : 0) + 2;
                    case "object":
                        if (null == t || "MinKey" === t._bsontype || "MaxKey" === t._bsontype) return (null != e ? Buffer$7.byteLength(e, "utf8") + 1 : 0) + 1;
                        if ("ObjectId" === t._bsontype || "ObjectID" === t._bsontype) return (null != e ? Buffer$7.byteLength(e, "utf8") + 1 : 0) + 13;
                        if (t instanceof Date || isDate$2(t)) return (null != e ? Buffer$7.byteLength(e, "utf8") + 1 : 0) + 9;
                        if (void 0 !== Buffer$7 && Buffer$7.isBuffer(t)) return (null != e ? Buffer$7.byteLength(e, "utf8") + 1 : 0) + 6 + t.length;
                        if ("Long" === t._bsontype || "Double" === t._bsontype || "Timestamp" === t._bsontype) return (null != e ? Buffer$7.byteLength(e, "utf8") + 1 : 0) + 9;
                        if ("Decimal128" === t._bsontype) return (null != e ? Buffer$7.byteLength(e, "utf8") + 1 : 0) + 17;
                        if ("Code" === t._bsontype) return null != t.scope && Object.keys(t.scope).length > 0 ? (null != e ? Buffer$7.byteLength(e, "utf8") + 1 : 0) + 1 + 4 + 4 + Buffer$7.byteLength(t.code.toString(), "utf8") + 1 + calculateObjectSize(t.scope, n, i) : (null != e ? Buffer$7.byteLength(e, "utf8") + 1 : 0) + 1 + 4 + Buffer$7.byteLength(t.code.toString(), "utf8") + 1;
                        if ("Binary" === t._bsontype) return t.sub_type === binary.SUBTYPE_BYTE_ARRAY ? (null != e ? Buffer$7.byteLength(e, "utf8") + 1 : 0) + (t.position + 1 + 4 + 1 + 4) : (null != e ? Buffer$7.byteLength(e, "utf8") + 1 : 0) + (t.position + 1 + 4 + 1);
                        if ("Symbol" === t._bsontype) return (null != e ? Buffer$7.byteLength(e, "utf8") + 1 : 0) + Buffer$7.byteLength(t.value, "utf8") + 4 + 1 + 1;
                        if ("DBRef" === t._bsontype) { var o = Object.assign({ $ref: t.collection, $id: t.oid }, t.fields); return null != t.db && (o.$db = t.db), (null != e ? Buffer$7.byteLength(e, "utf8") + 1 : 0) + 1 + calculateObjectSize(o, n, i) }
                        return t instanceof RegExp || "[object RegExp]" === Object.prototype.toString.call(t) ? (null != e ? Buffer$7.byteLength(e, "utf8") + 1 : 0) + 1 + Buffer$7.byteLength(t.source, "utf8") + 1 + (t.global ? 1 : 0) + (t.ignoreCase ? 1 : 0) + (t.multiline ? 1 : 0) + 1 : "BSONRegExp" === t._bsontype ? (null != e ? Buffer$7.byteLength(e, "utf8") + 1 : 0) + 1 + Buffer$7.byteLength(t.pattern, "utf8") + 1 + Buffer$7.byteLength(t.options, "utf8") + 1 : (null != e ? Buffer$7.byteLength(e, "utf8") + 1 : 0) + calculateObjectSize(t, n, i) + 1;
                    case "function":
                        if (t instanceof RegExp || "[object RegExp]" === Object.prototype.toString.call(t) || "[object RegExp]" === String.call(t)) return (null != e ? Buffer$7.byteLength(e, "utf8") + 1 : 0) + 1 + Buffer$7.byteLength(t.source, "utf8") + 1 + (t.global ? 1 : 0) + (t.ignoreCase ? 1 : 0) + (t.multiline ? 1 : 0) + 1;
                        if (n && null != t.scope && Object.keys(t.scope).length > 0) return (null != e ? Buffer$7.byteLength(e, "utf8") + 1 : 0) + 1 + 4 + 4 + Buffer$7.byteLength(normalizedFunctionString$2(t), "utf8") + 1 + calculateObjectSize(t.scope, n, i);
                        if (n) return (null != e ? Buffer$7.byteLength(e, "utf8") + 1 : 0) + 1 + 4 + Buffer$7.byteLength(normalizedFunctionString$2(t), "utf8") + 1
                }
                return 0
            }
            var calculate_size = calculateObjectSize,
                Buffer$8 = bufferEs6.Buffer,
                ensure_buffer = function(e) { if (e instanceof Buffer$8) return e; if (e instanceof Uint8Array) return Buffer$8.from(e.buffer); throw new TypeError("Must use either Buffer or Uint8Array") },
                Buffer$9 = bufferEs6.Buffer,
                MAXSIZE = 17825792,
                buffer = Buffer$9.alloc(MAXSIZE);

            function setInternalBufferSize(e) { buffer.length < e && (buffer = Buffer$9.alloc(e)) }

            function serialize$1(e, t) {
                var n = "boolean" == typeof(t = t || {}).checkKeys && t.checkKeys,
                    r = "boolean" == typeof t.serializeFunctions && t.serializeFunctions,
                    i = "boolean" != typeof t.ignoreUndefined || t.ignoreUndefined,
                    o = "number" == typeof t.minInternalBufferSize ? t.minInternalBufferSize : MAXSIZE;
                buffer.length < o && (buffer = Buffer$9.alloc(o));
                var a = serializer(buffer, e, n, 0, 0, r, i, []),
                    s = Buffer$9.alloc(a);
                return buffer.copy(s, 0, 0, s.length), s
            }

            function serializeWithBufferAndIndex(e, t, n) {
                var r = "boolean" == typeof(n = n || {}).checkKeys && n.checkKeys,
                    i = "boolean" == typeof n.serializeFunctions && n.serializeFunctions,
                    o = "boolean" != typeof n.ignoreUndefined || n.ignoreUndefined,
                    a = "number" == typeof n.index ? n.index : 0,
                    s = serializer(buffer, e, r, 0, 0, i, o);
                return buffer.copy(t, a, 0, s), a + s - 1
            }

            function deserialize$2(e, t) { return e = ensure_buffer(e), deserializer(e, t) }

            function calculateObjectSize$1(e, t) {
                var n = "boolean" == typeof(t = t || {}).serializeFunctions && t.serializeFunctions,
                    r = "boolean" != typeof t.ignoreUndefined || t.ignoreUndefined;
                return calculate_size(e, n, r)
            }

            function deserializeStream(e, t, n, r, i, o) {
                o = Object.assign({ allowObjectSmallerThanBufferSize: !0 }, o), e = ensure_buffer(e);
                for (var a = t, s = 0; s < n; s++) {
                    var u = e[a] | e[a + 1] << 8 | e[a + 2] << 16 | e[a + 3] << 24;
                    o.index = a, r[i + s] = deserializer(e, o), a += u
                }
                return a
            }
            var bson = { BSON_INT32_MAX: constants.BSON_INT32_MAX, BSON_INT32_MIN: constants.BSON_INT32_MIN, BSON_INT64_MAX: constants.BSON_INT64_MAX, BSON_INT64_MIN: constants.BSON_INT64_MIN, JS_INT_MAX: constants.JS_INT_MAX, JS_INT_MIN: constants.JS_INT_MIN, BSON_DATA_NUMBER: constants.BSON_DATA_NUMBER, BSON_DATA_STRING: constants.BSON_DATA_STRING, BSON_DATA_OBJECT: constants.BSON_DATA_OBJECT, BSON_DATA_ARRAY: constants.BSON_DATA_ARRAY, BSON_DATA_BINARY: constants.BSON_DATA_BINARY, BSON_DATA_UNDEFINED: constants.BSON_DATA_UNDEFINED, BSON_DATA_OID: constants.BSON_DATA_OID, BSON_DATA_BOOLEAN: constants.BSON_DATA_BOOLEAN, BSON_DATA_DATE: constants.BSON_DATA_DATE, BSON_DATA_NULL: constants.BSON_DATA_NULL, BSON_DATA_REGEXP: constants.BSON_DATA_REGEXP, BSON_DATA_DBPOINTER: constants.BSON_DATA_DBPOINTER, BSON_DATA_CODE: constants.BSON_DATA_CODE, BSON_DATA_SYMBOL: constants.BSON_DATA_SYMBOL, BSON_DATA_CODE_W_SCOPE: constants.BSON_DATA_CODE_W_SCOPE, BSON_DATA_INT: constants.BSON_DATA_INT, BSON_DATA_TIMESTAMP: constants.BSON_DATA_TIMESTAMP, BSON_DATA_LONG: constants.BSON_DATA_LONG, BSON_DATA_DECIMAL128: constants.BSON_DATA_DECIMAL128, BSON_DATA_MIN_KEY: constants.BSON_DATA_MIN_KEY, BSON_DATA_MAX_KEY: constants.BSON_DATA_MAX_KEY, BSON_BINARY_SUBTYPE_DEFAULT: constants.BSON_BINARY_SUBTYPE_DEFAULT, BSON_BINARY_SUBTYPE_FUNCTION: constants.BSON_BINARY_SUBTYPE_FUNCTION, BSON_BINARY_SUBTYPE_BYTE_ARRAY: constants.BSON_BINARY_SUBTYPE_BYTE_ARRAY, BSON_BINARY_SUBTYPE_UUID: constants.BSON_BINARY_SUBTYPE_UUID, BSON_BINARY_SUBTYPE_MD5: constants.BSON_BINARY_SUBTYPE_MD5, BSON_BINARY_SUBTYPE_USER_DEFINED: constants.BSON_BINARY_SUBTYPE_USER_DEFINED, Code: code, Map: map, BSONSymbol: symbol, DBRef: db_ref, Binary: binary, ObjectId: objectid, Long: long_1$1, Timestamp: timestamp, Double: double_1, Int32: int_32, MinKey: min_key, MaxKey: max_key, BSONRegExp: regexp, Decimal128: decimal128, serialize: serialize$1, serializeWithBufferAndIndex: serializeWithBufferAndIndex, deserialize: deserialize$2, calculateObjectSize: calculateObjectSize$1, deserializeStream: deserializeStream, setInternalBufferSize: setInternalBufferSize, ObjectID: objectid, EJSON: extended_json },
                bson_1 = bson.BSON_INT32_MAX,
                bson_2 = bson.BSON_INT32_MIN,
                bson_3 = bson.BSON_INT64_MAX,
                bson_4 = bson.BSON_INT64_MIN,
                bson_5 = bson.JS_INT_MAX,
                bson_6 = bson.JS_INT_MIN,
                bson_7 = bson.BSON_DATA_NUMBER,
                bson_8 = bson.BSON_DATA_STRING,
                bson_9 = bson.BSON_DATA_OBJECT,
                bson_10 = bson.BSON_DATA_ARRAY,
                bson_11 = bson.BSON_DATA_BINARY,
                bson_12 = bson.BSON_DATA_UNDEFINED,
                bson_13 = bson.BSON_DATA_OID,
                bson_14 = bson.BSON_DATA_BOOLEAN,
                bson_15 = bson.BSON_DATA_DATE,
                bson_16 = bson.BSON_DATA_NULL,
                bson_17 = bson.BSON_DATA_REGEXP,
                bson_18 = bson.BSON_DATA_DBPOINTER,
                bson_19 = bson.BSON_DATA_CODE,
                bson_20 = bson.BSON_DATA_SYMBOL,
                bson_21 = bson.BSON_DATA_CODE_W_SCOPE,
                bson_22 = bson.BSON_DATA_INT,
                bson_23 = bson.BSON_DATA_TIMESTAMP,
                bson_24 = bson.BSON_DATA_LONG,
                bson_25 = bson.BSON_DATA_DECIMAL128,
                bson_26 = bson.BSON_DATA_MIN_KEY,
                bson_27 = bson.BSON_DATA_MAX_KEY,
                bson_28 = bson.BSON_BINARY_SUBTYPE_DEFAULT,
                bson_29 = bson.BSON_BINARY_SUBTYPE_FUNCTION,
                bson_30 = bson.BSON_BINARY_SUBTYPE_BYTE_ARRAY,
                bson_31 = bson.BSON_BINARY_SUBTYPE_UUID,
                bson_32 = bson.BSON_BINARY_SUBTYPE_MD5,
                bson_33 = bson.BSON_BINARY_SUBTYPE_USER_DEFINED,
                bson_34 = bson.Code,
                bson_35 = bson.BSONSymbol,
                bson_36 = bson.DBRef,
                bson_37 = bson.Binary,
                bson_38 = bson.ObjectId,
                bson_39 = bson.Long,
                bson_40 = bson.Timestamp,
                bson_41 = bson.Double,
                bson_42 = bson.Int32,
                bson_43 = bson.MinKey,
                bson_44 = bson.MaxKey,
                bson_45 = bson.BSONRegExp,
                bson_46 = bson.Decimal128,
                bson_47 = bson.serialize,
                bson_48 = bson.serializeWithBufferAndIndex,
                bson_49 = bson.deserialize,
                bson_50 = bson.calculateObjectSize,
                bson_51 = bson.deserializeStream,
                bson_52 = bson.setInternalBufferSize,
                bson_53 = bson.ObjectID,
                bson_54 = bson.EJSON;
            return exports.default = bson, exports.BSON_INT32_MAX = bson_1, exports.BSON_INT32_MIN = bson_2, exports.BSON_INT64_MAX = bson_3, exports.BSON_INT64_MIN = bson_4, exports.JS_INT_MAX = bson_5, exports.JS_INT_MIN = bson_6, exports.BSON_DATA_NUMBER = bson_7, exports.BSON_DATA_STRING = bson_8, exports.BSON_DATA_OBJECT = bson_9, exports.BSON_DATA_ARRAY = bson_10, exports.BSON_DATA_BINARY = bson_11, exports.BSON_DATA_UNDEFINED = bson_12, exports.BSON_DATA_OID = bson_13, exports.BSON_DATA_BOOLEAN = bson_14, exports.BSON_DATA_DATE = bson_15, exports.BSON_DATA_NULL = bson_16, exports.BSON_DATA_REGEXP = bson_17, exports.BSON_DATA_DBPOINTER = bson_18, exports.BSON_DATA_CODE = bson_19, exports.BSON_DATA_SYMBOL = bson_20, exports.BSON_DATA_CODE_W_SCOPE = bson_21, exports.BSON_DATA_INT = bson_22, exports.BSON_DATA_TIMESTAMP = bson_23, exports.BSON_DATA_LONG = bson_24, exports.BSON_DATA_DECIMAL128 = bson_25, exports.BSON_DATA_MIN_KEY = bson_26, exports.BSON_DATA_MAX_KEY = bson_27, exports.BSON_BINARY_SUBTYPE_DEFAULT = bson_28, exports.BSON_BINARY_SUBTYPE_FUNCTION = bson_29, exports.BSON_BINARY_SUBTYPE_BYTE_ARRAY = bson_30, exports.BSON_BINARY_SUBTYPE_UUID = bson_31, exports.BSON_BINARY_SUBTYPE_MD5 = bson_32, exports.BSON_BINARY_SUBTYPE_USER_DEFINED = bson_33, exports.Code = bson_34, exports.BSONSymbol = bson_35, exports.DBRef = bson_36, exports.Binary = bson_37, exports.ObjectId = bson_38, exports.Long = bson_39, exports.Timestamp = bson_40, exports.Double = bson_41, exports.Int32 = bson_42, exports.MinKey = bson_43, exports.MaxKey = bson_44, exports.BSONRegExp = bson_45, exports.Decimal128 = bson_46, exports.serialize = bson_47, exports.serializeWithBufferAndIndex = bson_48, exports.deserialize = bson_49, exports.calculateObjectSize = bson_50, exports.deserializeStream = bson_51, exports.setInternalBufferSize = bson_52, exports.ObjectID = bson_53, exports.EJSON = bson_54, exports
        }({})
    }).call(this, __webpack_require__(32), __webpack_require__(70).Buffer)
}, function(e, t, n) {
    "use strict";
    n.d(t, "b", function() { return a }), n.d(t, "c", function() { return s }), n.d(t, "a", function() { return u });
    var r = n(0),
        i = n(7),
        o = n(15),
        a = function(e) {
            var t = e.url,
                n = e.data,
                r = e.dataType,
                o = e.header,
                a = e.responseType,
                s = e.method || "POST",
                u = new XMLHttpRequest;
            u.withCredentials = !0, u.responseType = a || "text", u.timeout = 6e4, u.open(s, t, !0), u.onreadystatechange = function() {
                if (4 === u.readyState) {
                    u.onreadystatechange = null;
                    var t = u.status;
                    if (0 === t);
                    else {
                        var n = { errMsg: "request:ok", header: Object(i.c)(u), statusCode: t };
                        if (n.data = "arraybuffer" === a ? u.response : u.responseText, "json" === r) try { n.data = JSON.parse(n.data) } catch (t) { return n.errMsg = "request:fail JSON parse response body error: " + t, void Object(i.a)(e, n) }
                        Object(i.b)(e, n)
                    }
                }
            }, u.onerror = function(t) { Object(i.a)(e, { errMsg: "request:fail " + u.status + " " + u.statusText + " " + t }) }, u.ontimeout = function() { Object(i.a)(e, { errMsg: "request:fail timeout" }) }, u.onabort = function() { Object(i.a)(e, { errMsg: "request:fail abort" }) };
            var c = o || {};
            for (var f in c["Content-Type"] || "json" !== r || (c["Content-Type"] = "application/json"), c)
                if (c.hasOwnProperty(f)) try { u.setRequestHeader(f, c[f]) } catch (t) { return void Object(i.a)(e, { errMsg: "request:fail Failed to execute 'setRequestHeader' 鈥MLHttpRequest': Value is not a valid ByteString." }) }
            try { u.send(n) } catch (t) { Object(i.a)(e, { errMsg: "request:fail " + t }) }
            return { abort: function() { try { u.abort(), Object(i.b)(e, { errMsg: "request:ok" }) } catch (t) { Object(i.a)(e, { errMsg: "request:fail abort" }) } } }
        };

    function s(e) {
        return Object(r.b)(this, void 0, void 0, function() {
            return Object(r.d)(this, function(t) {
                return [2, new Promise(function(t, n) {
                    var i = a(Object(r.a)(Object(r.a)({}, e), {
                        dataType: "json",
                        data: JSON.stringify(e.json),
                        success: function(e) {
                            if (200 === e.statusCode) {
                                var r = e.data;
                                r.base_resp ? 0 === r.base_resp.ret ? t(e) : n(Object(o.b)(r.base_resp.ret, "errCode " + r.base_resp.ret + ". body " + JSON.stringify(e.data))) : n(Object(o.b)(-104, "[system error] lack of base_resp. body " + JSON.stringify(e.data)))
                            } else n(Object(o.b)(-103, "statusCode " + e.statusCode + " body " + JSON.stringify(e.data)))
                        },
                        fail: function(e) { n(e) }
                    }));
                    e.onRequestTaskReady && i && e.onRequestTaskReady(i)
                })]
            })
        })
    }
    var u = function(e) {
        return function t(n) {
            var i = this;
            return new Promise(function(a, u) {
                return Object(r.b)(i, void 0, void 0, function() {
                    var i, c, f, l, d, h, p, _;
                    return Object(r.d)(this, function(b) {
                        switch (b.label) {
                            case 0:
                                i = null === (p = n.addAuth) || void 0 === p || p, c = null !== (_ = n.maxAuthRetry) && void 0 !== _ ? _ : 1, b.label = 1;
                            case 1:
                                return b.trys.push([1, 3, , 4]), f = Object(r.a)({}, n.json), !e.instanceOptions.identityless && i && (l = e.authStorage, f.access_token = l.getItem("access_token")), [4, s(Object(r.a)(Object(r.a)({}, n), { json: f }))];
                            case 2:
                                return d = b.sent(), a(d), [3, 4];
                            case 3:
                                switch ((h = b.sent()).errCode) {
                                    case o.a.INVALID_CREDENTIAL:
                                    case o.a.EXPIRED_ACCESS_TOKEN:
                                        if (i && c > 0) return a(e.webRefreshToken().then(function() { return t(Object(r.a)(Object(r.a)({}, n), { maxAuthRetry: c - 1 })) })), [2]
                                }
                                return u(h), [3, 4];
                            case 4:
                                return [2]
                        }
                    })
                })
            })
        }
    }
}, function(e, t) {
    var n;
    n = function() { return this }();
    try { n = n || Function("return this")() || (0, eval)("this") } catch (e) { "object" == typeof window && (n = window) }
    e.exports = n
}, function(e, t, n) {
    "use strict";
    var r = n(19),
        i = n(12),
        o = "[object AsyncFunction]",
        a = "[object Function]",
        s = "[object GeneratorFunction]",
        u = "[object Proxy]";
    t.a = function(e) { if (!Object(i.a)(e)) return !1; var t = Object(r.a)(e); return t == a || t == s || t == o || t == u }
}, function(e, t, n) {
    "use strict";
    (function(e) {
        var r = n(11),
            i = n(65),
            o = "object" == typeof exports && exports && !exports.nodeType && exports,
            a = o && "object" == typeof e && e && !e.nodeType && e,
            s = a && a.exports === o ? r.a.Buffer : void 0,
            u = (s ? s.isBuffer : void 0) || i.a;
        t.a = u
    }).call(this, n(62)(e))
}, function(e, t, n) {
    "use strict";
    var r = Object.prototype;
    t.a = function(e) { var t = e && e.constructor; return e === ("function" == typeof t && t.prototype || r) }
}, function(e, t, n) {
    "use strict";
    var r = n(54),
        i = Object(r.a)(Object.getPrototypeOf, Object);
    t.a = i
}, function(e, t, n) {
    "use strict";
    var r = n(42);
    t.a = function(e, t, n) { "__proto__" == t && r.a ? Object(r.a)(e, t, { configurable: !0, enumerable: !0, value: n, writable: !0 }) : e[t] = n }
}, function(e, t, n) {
    "use strict";
    var r = n(37),
        i = n(25),
        o = Object.prototype.hasOwnProperty;
    t.a = function(e, t, n) {
        var a = e[t];
        o.call(e, t) && Object(i.a)(a, n) && (void 0 !== n || t in e) || Object(r.a)(e, t, n)
    }
}, function(e, t, n) {
    "use strict";
    t.a = function(e) { return function(t) { return e(t) } }
}, function(e, t, n) {
    "use strict";
    var r = 9007199254740991,
        i = /^(?:0|[1-9]\d*)$/;
    t.a = function(e, t) { var n = typeof e; return !!(t = null == t ? r : t) && ("number" == n || "symbol" != n && i.test(e)) && e > -1 && e % 1 == 0 && e < t }
}, function(e, t, n) {
    "use strict";
    var r = n(11).a.Uint8Array;
    t.a = function(e) { var t = new e.constructor(e.byteLength); return new r(t).set(new r(e)), t }
}, function(e, t, n) {
    "use strict";
    var r = n(17),
        i = function() { try { var e = Object(r.a)(Object, "defineProperty"); return e({}, "", {}), e } catch (e) {} }();
    t.a = i
}, function(e, t, n) {
    "use strict";
    n.d(t, "d", function() { return s }), n.d(t, "a", function() { return u }), n.d(t, "c", function() { return c });
    var r = n(0),
        i = n(1),
        o = n(9),
        a = new(function() {
            function e() { this._running = 0, this._onIdleCallbacks = [] }
            return Object.defineProperty(e.prototype, "running", { get: function() { return this._running }, enumerable: !1, configurable: !0 }), e.prototype.incrementRunning = function(e) { void 0 === e && (e = 1), this._running += e, this._idleTriggerTimer && clearTimeout(this._idleTriggerTimer) }, e.prototype.decrementRunning = function(e) {
                var t = this;
                void 0 === e && (e = 1), this._running -= e, this._running < 0 && (this._running = 0), this._running <= 0 && this._onIdleCallbacks.length && (this._idleTriggerTimer = setTimeout(function() {
                    if (t._idleTriggerTimer = null, t._onIdleCallbacks.length) {
                        var e = t._onIdleCallbacks.shift();
                        e && e()
                    }
                }, 50))
            }, e.prototype.onceIdle = function(e) { this._running > 0 ? this._onIdleCallbacks.push(e) : e() }, e
        }());

    function s(e, t) {
        var n = this;
        if (void 0 === t && (t = {}), t.fireOnIdle && a.running > 0) return new Promise(function(i, o) {
            a.onceIdle(function() {
                return Object(r.b)(n, void 0, void 0, function() {
                    var n, a;
                    return Object(r.d)(this, function(r) {
                        switch (r.label) {
                            case 0:
                                return r.trys.push([0, 2, , 3]), [4, s(e, t)];
                            case 1:
                                return n = r.sent(), i(n), [3, 3];
                            case 2:
                                return a = r.sent(), o(a), [3, 3];
                            case 3:
                                return [2]
                        }
                    })
                })
            })
        });
        if (t.onFire) try { t.onFire() } catch (e) {}
        return new Promise(function(n, s) {
            var u, c, f, l, d;
            a.incrementRunning(), Object(o.a)((e.cloud || t.cloud || {}).identifiers)._operateWXData({
                appid: null === (c = null === (u = e.cloud) || void 0 === u ? void 0 : u.instanceOptions) || void 0 === c ? void 0 : c.resourceAppid,
                accessToken: null === (l = null === (f = e.cloud) || void 0 === f ? void 0 : f.authStorage) || void 0 === l ? void 0 : l.getItem("access_token"),
                webRequest: null === (d = e.cloud) || void 0 === d ? void 0 : d.webRequest,
                apiName: e.apiName || "qbase_commapi",
                reqData: e.data,
                requestInQueue: !1,
                success: function(e) {
                    var o = Object(r.a)(Object(r.a)({}, e), { data: e.rawData });
                    if (e.rawData) try {
                            var a = JSON.parse(e.rawData);
                            if (a.baseresponse && 0 !== a.baseresponse.errcode) { var u = new i.b({ errCode: a.baseresponse.errcode, errMsg: a.baseresponse.errmsg }); return void s(u) }
                            o = Object(r.a)(Object(r.a)({}, e), { data: a })
                        } catch (e) { u = new i.b({ errMsg: e && e.toString() }); return void s(u) } else if (t && t.requireDataNotEmpty) { u = new i.b({ errCode: e.errCode, errMsg: "error empty internal server response, " + e.errMsg }); return void s(u) }
                    n(o)
                },
                fail: function(e) {
                    if (e && e.errMsg)
                        if (e.errMsg.includes("invalid scope")) {
                            var t = "invalid scope 娌℃湁鏉冮檺锛岃鍏堝紑閫氫簯鏈嶅姟";
                            (e = new Error(t)).errMsg = t, e.operateWXDataFail = !0
                        } else {
                            t = e.errMsg.replace(/^operateWXData:fail /, "");
                            (e = new Error(t)).errMsg = t, e.operateWXDataFail = !0
                        }
                    s(e)
                },
                complete: function() { e.complete && e.complete.apply(null, arguments), a.decrementRunning() }
            })
        })
    }

    function u(e) { var t = e.cloud; return { apiName: "qbase_commapi", data: { qbase_api_name: e.apiName, qbase_req: e.serializedReqData, qbase_options: { env: e.env }, qbase_meta: t.getMetaData(), cli_req_id: +new Date + "_" + Math.random() }, cloud: t } }

    function c(e) { var t = e.cloud; return function(e) { var n = t.isInstance ? { appid: t.instanceOptions.resourceAppid, env: t.instanceOptions.resourceEnv } : { env: e.env }; return s({ apiName: "qbase_commapi", data: { qbase_api_name: e.apiName, qbase_req: e.serializedReqData, qbase_options: n, qbase_meta: t.getMetaData(), cli_req_id: +new Date + "_" + Math.random() }, cloud: t }) } }
    t.b = s
}, function(e, t, n) {
    "use strict";
    var r = n(9),
        i = n(0),
        o = n(7),
        a = n(31),
        s = {
            getNetworkType: function(e) { Object(o.b)(e, { errMsg: "getNetworkType:ok", networkType: f() }) },
            onNetworkStatusChange: function(e) {
                (function() {
                    if (u) return;
                    u = !0, navigator.connection.onchange = function() { c.forEach(function(e) { try { e(f()) } catch (e) {} }) }
                })(), c.push(e)
            },
            onAppShow: function() {},
            onAppHide: function() {},
            version: { version: "web", updateTime: "" }
        },
        u = !1,
        c = [];

    function f() {
        var e = navigator.connection;
        if (e) switch (e.type) {
            case "wifi":
                return "wifi";
            case "none":
                return "none"
        }
        return "unknown"
    }
    var l = {
        _operateWXData: function(e) {
            return Object(i.b)(void 0, void 0, void 0, function() {
                var t, n, r, a;
                return Object(i.d)(this, function(i) {
                    switch (i.label) {
                        case 0:
                            if (i.trys.push([0, 2, , 3]), !e.appid) throw new Error("missing appid");
                            return t = { appid: e.appid, data: e.reqData }, [4, e.webRequest({ url: "https://servicewechat.com/wxa-qbase/jsoperatewxdata", method: "POST", json: t })];
                        case 1:
                            return n = i.sent(), 0 === (r = n.data).base_resp.ret ? Object(o.b)(e, { rawData: r.data }) : Object(o.a)(e, { errMsg: "operateWXData:fail base_resp.ret " + r.base_resp.ret }), [3, 3];
                        case 2:
                            return a = i.sent(), Object(o.a)(e, a), [3, 3];
                        case 3:
                            return [2]
                    }
                })
            })
        },
        _uploadFileSkipCheckDomain: function(e) {
            var t, n = e.url,
                r = e.header,
                i = e.formData,
                a = new XMLHttpRequest;
            for (var s in a.responseType = "text", a.timeout = 6e4, a.open("POST", n, !0), a.onreadystatechange = function() {
                    if (4 === a.readyState) {
                        a.onreadystatechange = null;
                        var t = a.status;
                        if (0 === t);
                        else {
                            var n = { errMsg: "uploadFile:ok", header: Object(o.c)(a), statusCode: t };
                            n.data = a.responseText, Object(o.b)(e, n)
                        }
                    }
                }, a.onerror = function() { Object(o.a)(e, { errMsg: "uploadFile:fail" }) }, a.ontimeout = function() { Object(o.a)(e, { errMsg: "uploadFile:fail timeout" }) }, a.onabort = function() { Object(o.a)(e, { errMsg: "uploadFile:fail abort" }) }, a.onprogress = function(e) { t && t({ progress: e.loaded / e.total, totalBytesWritten: e.loaded, totalBytesExpectedToWrite: e.total }) }, r)
                if (r.hasOwnProperty(s)) try { a.setRequestHeader(s, r[s]) } catch (t) { return void Object(o.a)(e, { errMsg: "uploadFile:fail Failed to execute 'setRequestHeader' 鈥MLHttpRequest': Value is not a valid ByteString." }) }
            try { a.send(i) } catch (t) { Object(o.a)(e, { errMsg: "uploadFile:fail" }) }
            return { abort: function() { try { a.abort(), Object(o.b)(e, { errMsg: "uploadFile:ok" }) } catch (t) { Object(o.a)(e, { errMsg: "uploadFile:fail abort" }) } }, onProgressUpdate: function(e) { t = e } }
        },
        _downloadFileSkipCheckDomain: function(e) {
            var t, n = e.url,
                r = e.header,
                i = new XMLHttpRequest;
            for (var a in i.responseType = "arraybuffer", i.timeout = e.timeout || 6e4, i.open("GET", n, !0), i.onreadystatechange = function() {
                    if (4 === i.readyState) {
                        i.onreadystatechange = null;
                        var t = i.status;
                        if (0 === t);
                        else {
                            var n = { errMsg: "downloadFile:ok", header: Object(o.c)(i), statusCode: t };
                            n.data = i.response, Object(o.b)(e, n)
                        }
                    }
                }, i.onerror = function() { Object(o.a)(e, { errMsg: "downloadFile:fail" }) }, i.ontimeout = function() { Object(o.a)(e, { errMsg: "downloadFile:fail timeout" }) }, i.onabort = function() { Object(o.a)(e, { errMsg: "downloadFile:fail abort" }) }, i.onprogress = function(e) { t && t({ progress: e.loaded / e.total, totalBytesWritten: e.loaded, totalBytesExpectedToWrite: e.total }) }, r)
                if (r.hasOwnProperty(a)) try { i.setRequestHeader(a, r[a]) } catch (t) { return void Object(o.a)(e, { errMsg: "downloadFile:fail Failed to execute 'setRequestHeader' 鈥MLHttpRequest': Value is not a valid ByteString." }) }
            try { i.send() } catch (t) { Object(o.a)(e, { errMsg: "downloadFile:fail" }) }
            return { abort: function() { try { i.abort(), Object(o.b)(e, { errMsg: "downloadFile:ok" }) } catch (t) { Object(o.a)(e, { errMsg: "downloadFile:fail abort" }) } }, onProgressUpdate: function(e) { t = e } }
        },
        _requestSkipCheckDomain: a.b,
        _socketSkipCheckDomainFactory: function() {
            return {
                connectSocket: function(e) {
                    var t, n;
                    try { t = new WebSocket(e.url, e.protocols), Object(o.b)(e, void 0) } catch (t) { n = t, Object(o.a)(e, t) }
                    if (!n) return setTimeout(function() { return Object(o.b)(e, void 0) }), {get readyState() { return t.readyState }, send: function(e) { t.send(e.data), Object(o.b)(e, {}) }, close: function(e) { t.close(null === e || void 0 === e ? void 0 : e.code, null === e || void 0 === e ? void 0 : e.reason), Object(o.b)(e, {}) }, onOpen: function(e) { t.onopen = function() { return e({ header: {} }) } }, onClose: function(e) { t.onclose = e }, onError: function(e) { t.onclose = e }, onMessage: function(e) { t.onmessage = e } };
                    setTimeout(function() { return Object(o.a)(e, n) })
                }
            }
        },
        uploadToCommonCDN: function(e) { Object(o.a)(e, { errMsg: "uploadToCommonCDN:fail not supported in web" }) },
        wx: s
    };
    Object(r.b)(l);
    var d = n(50),
        h = n(49);
    n.d(t, !1, function() {}), n.d(t, "a", function() { return d.a }), n.d(t, !1, function() { return a.b }), n.d(t, !1, function() { return a.c }), n.d(t, "b", function() { return a.a }), n.d(t, !1, function() {}), n.d(t, !1, function() { return h.a }), n.d(t, !1, function() {}), n.d(t, !1, function() {})
}, function(e, t, n) {
    "use strict";
    n.d(t, "a", function() { return i });
    n(44);
    var r = { env: "", platform: "" },
        i = function() { return r };
    if ("undefined" != typeof __wxConfig) r.env = "miniprogram", r.platform = __wxConfig.platform;
    else if (r.env = "web", window.__wxjs_environment && "miniprogram" === window.__wxjs_environment) r.platform = "miniprogram";
    else { var o = window.navigator.userAgent.toLowerCase(); /MicroMessenger/i.test(o) && (r.platform = "wxweb") }
}, function(e, t, n) {
    "use strict";
    var r = n(17),
        i = Object(r.a)(Object, "create");
    var o = function() { this.__data__ = i ? i(null) : {}, this.size = 0 };
    var a = function(e) { var t = this.has(e) && delete this.__data__[e]; return this.size -= t ? 1 : 0, t },
        s = "__lodash_hash_undefined__",
        u = Object.prototype.hasOwnProperty;
    var c = function(e) { var t = this.__data__; if (i) { var n = t[e]; return n === s ? void 0 : n } return u.call(t, e) ? t[e] : void 0 },
        f = Object.prototype.hasOwnProperty;
    var l = function(e) { var t = this.__data__; return i ? void 0 !== t[e] : f.call(t, e) },
        d = "__lodash_hash_undefined__";
    var h = function(e, t) { var n = this.__data__; return this.size += this.has(e) ? 0 : 1, n[e] = i && void 0 === t ? d : t, this };

    function p(e) {
        var t = -1,
            n = null == e ? 0 : e.length;
        for (this.clear(); ++t < n;) {
            var r = e[t];
            this.set(r[0], r[1])
        }
    }
    p.prototype.clear = o, p.prototype.delete = a, p.prototype.get = c, p.prototype.has = l, p.prototype.set = h;
    var _ = p,
        b = n(27),
        g = n(29);
    var E = function() { this.size = 0, this.__data__ = { hash: new _, map: new(g.a || b.a), string: new _ } };
    var O = function(e) { var t = typeof e; return "string" == t || "number" == t || "symbol" == t || "boolean" == t ? "__proto__" !== e : null === e };
    var y = function(e, t) { var n = e.__data__; return O(t) ? n["string" == typeof t ? "string" : "hash"] : n.map };
    var m = function(e) { var t = y(this, e).delete(e); return this.size -= t ? 1 : 0, t };
    var T = function(e) { return y(this, e).get(e) };
    var v = function(e) { return y(this, e).has(e) };
    var S = function(e, t) {
        var n = y(this, e),
            r = n.size;
        return n.set(e, t), this.size += n.size == r ? 0 : 1, this
    };

    function N(e) {
        var t = -1,
            n = null == e ? 0 : e.length;
        for (this.clear(); ++t < n;) {
            var r = e[t];
            this.set(r[0], r[1])
        }
    }
    N.prototype.clear = E, N.prototype.delete = m, N.prototype.get = T, N.prototype.has = v, N.prototype.set = S;
    t.a = N
}, function(e, t, n) {
    "use strict";
    var r = n(19),
        i = n(14),
        o = "[object Arguments]";
    var a = function(e) { return Object(i.a)(e) && Object(r.a)(e) == o },
        s = Object.prototype,
        u = s.hasOwnProperty,
        c = s.propertyIsEnumerable,
        f = a(function() { return arguments }()) ? a : function(e) { return Object(i.a)(e) && u.call(e, "callee") && !c.call(e, "callee") };
    t.a = f
}, function(e, t, n) {
    "use strict";
    n.d(t, "a", function() { return r });
    var r = { REALTIME_DB_MAX_RECONNECT: 5, REALTIME_DB_WS_RECONNECT_INTERVAL: 5e3, REALTIME_DB_TOTAL_CONNECTION_TIMEOUT: 1 / 0 };
    t.b = { db_doc_size_limit: 524288, db_realtime_ping_interval: 15e3, db_realtime_pong_wait_timeout: 15e3, db_realtime_query_event_cache_timeout: 18e4, upload_max_file_size: 20971520, get_temp_file_url_max_requests: 50, call_function_poll_max_retry: 10, call_function_max_req_data_size: 5242880, call_function_client_poll_timeout: 15e3, call_function_valid_start_retry_gap: 6e4 }
}, function(e, t, n) {
    "use strict";
    n.d(t, "a", function() { return u });
    var r = "wxcloudbase_",
        i = r + "_persistence",
        o = {},
        a = localStorage.getItem(i) || "local",
        s = function() {
            function e(e) { this.prefix = "" + r + e.provider + "_" + e.id + "_", this.storage = "session" === a ? sessionStorage : localStorage }
            return e.prototype.setItem = function(e, t) { this.storage.setItem(this.getKeyFullName(e), t) }, e.prototype.getItem = function(e) { return this.storage.getItem(this.getKeyFullName(e)) }, e.prototype.getKeyFullName = function(e) { return "" + this.prefix + e }, e
        }();

    function u(e) {
        var t = e.provider + "_" + e.id,
            n = o[t];
        return n || (n = new s(e), o[t] = n, n)
    }
}, function(e, t, n) {
    "use strict";
    var r = n(0),
        i = n(31),
        o = n(49),
        a = n(15),
        s = "cloud.checkLogin";

    function u(e) {
        var t = {};
        return function(u) {
            return Object(r.b)(this, void 0, void 0, function() {
                var c, f;
                return Object(r.d)(this, function(l) {
                    if (c = u.provider + "_" + u.appid, t[c]) return [2, t[c]];
                    try {
                        return f = void 0, "OfficialAccount" === u.provider && (f = function(t) {
                            return Object(r.b)(this, void 0, void 0, function() {
                                var s, u, c, f, l, d, h, p, _, b, g = this;
                                return Object(r.d)(this, function(E) {
                                    switch (E.label) {
                                        case 0:
                                            if (s = t.provider, u = t.appid, c = t.ignoreUrl, !u) throw new Error("appid must be provided");
                                            if (f = Object(o.a)({ provider: s, id: u }), l = t.accessToken, d = t.refreshToken, c || l && d || (h = new URLSearchParams(location.search), l = h.get("access_token"), d = h.get("refresh_token")), l && d || (l = f.getItem("access_token"), d = f.getItem("refresh_token")), !l || !d) return [3, 4];
                                            E.label = 1;
                                        case 1:
                                            return E.trys.push([1, 3, , 4]), [4, n(u, l).catch(function(e) {
                                                return Object(r.b)(g, void 0, void 0, function() {
                                                    return Object(r.d)(this, function(t) {
                                                        switch (t.label) {
                                                            case 0:
                                                                return (null === e || void 0 === e ? void 0 : e.errCode) !== a.a.INVALID_CREDENTIAL && (null === e || void 0 === e ? void 0 : e.errCode) !== a.a.EXPIRED_ACCESS_TOKEN ? [3, 2] : [4, function(e, t) {
                                                                    return Object(r.b)(this, void 0, void 0, function() {
                                                                        var n;
                                                                        return Object(r.d)(this, function(r) {
                                                                            switch (r.label) {
                                                                                case 0:
                                                                                    return [4, Object(i.c)({ url: "https://servicewechat.com/wxa-qbase/refresh_token", method: "POST", json: { appid: e, refresh_token: t } })];
                                                                                case 1:
                                                                                    return n = r.sent(), [2, n.data.access_token]
                                                                            }
                                                                        })
                                                                    })
                                                                }(u, d)];
                                                            case 1:
                                                                return l = t.sent(), [2, n(u, l)];
                                                            case 2:
                                                                throw e
                                                        }
                                                    })
                                                })
                                            })];
                                        case 2:
                                            return p = E.sent().data, f.setItem("access_token", l), f.setItem("refresh_token", d), e.cloud.authStorage = f, _ = { errCode: 0, loggedIn: !0 }, p && p.cloudid && (_.cloudID = p.cloudid), [2, _];
                                        case 3:
                                            switch (null === (b = E.sent()) || void 0 === b ? void 0 : b.errCode) {
                                                case a.a.INVALID_REFRESH_TOKEN:
                                                case a.a.INVALID_ACCESS_TOKEN:
                                                case a.a.INVALID_CREDENTIAL:
                                                case a.a.EXPIRED_ACCESS_TOKEN:
                                                case a.a.EXPIRED_REFRESH_TOKEN:
                                                case a.a.NO_SESSION_IN_COOKIE:
                                                case a.a.INVALID_ARGS:
                                                    return [2, { errCode: 0, loggedIn: !1 }]
                                            }
                                            throw b;
                                        case 4:
                                            return [2, { errCode: 0, loggedIn: !1 }]
                                    }
                                })
                            })
                        }(u)), f && (t[c] = f), [2, f]
                    } catch (e) { throw (null === e || void 0 === e ? void 0 : e.errCode) && (e.message = s + " " + e.message, e.errMsg = e.message), e } finally { delete t[c] }
                    return [2]
                })
            })
        };

        function n(e, t) { return Object(r.b)(this, void 0, void 0, function() { return Object(r.d)(this, function(n) { return [2, Object(i.c)({ url: "https://servicewechat.com/wxa-qbase/check_login", method: "POST", json: { appid: e, access_token: t } })] }) }) }
    }
    var c = n(5);

    function f(e) {
        return function(e) {
            "OfficialAccount" === e.provider && function(e) {
                Object(c.d)(e, { appid: "string", scope: "string", redirectUri: "string" });
                var t = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + e.appid + "&scope=" + e.scope + "&redirect_uri=" + encodeURIComponent(e.redirectUri) + "&state=WECHAT_STATE_QBASE&response_type=code#wechat_redirect";
                location.href = t
            }(e)
        }
    }

    function l(e) {
        return function(t) {
            return function(t) {
                return Object(r.b)(this, void 0, void 0, function() {
                    var n, i;
                    return Object(r.d)(this, function(r) {
                        switch (r.label) {
                            case 0:
                                return r.trys.push([0, 2, , 3]), [4, e.cloud.webRequest({ url: "https://servicewechat.com/wxa-qbase/check_login", method: "POST", json: { appid: e.cloud.instanceOptions.appid, url: t.url } })];
                            case 1:
                                return n = r.sent(), [2, { errCode: 0, timestamp: (i = n.data).jssdk_info.timestamp, nonceStr: i.jssdk_info.noncestr, signature: i.jssdk_info.signature }];
                            case 2:
                                throw r.sent();
                            case 3:
                                return [2]
                        }
                    })
                })
            }(t)
        }
    }
    var d = "cloud.refreshAuth";

    function h(e) {
        return {
            checkLogin: { initRequired: !1, fn: u(e) },
            startLogin: { initRequired: !1, fn: f() },
            getJSSDKSignature: { initRequired: !0, fn: l(e) },
            refreshAuth: {
                initRequired: !0,
                fn: function(e) {
                    var t;
                    return function(n) {
                        return Object(r.b)(this, void 0, void 0, function() {
                            var n, i;
                            return Object(r.d)(this, function(r) {
                                switch (r.label) {
                                    case 0:
                                        if (t) return [2, t];
                                        r.label = 1;
                                    case 1:
                                        return r.trys.push([1, 3, 4, 5]), n = e.cloud, [4, t = n.webRequest({ url: "https://servicewechat.com/wxa-qbase/get_env_auth", method: "POST", json: { appid: n.instanceOptions.appid, resource_appid: n.instanceOptions.resourceAppid, resource_env: n.instanceOptions.resourceEnv } })];
                                    case 2:
                                        return r.sent(), [3, 5];
                                    case 3:
                                        throw (null === (i = r.sent()) || void 0 === i ? void 0 : i.errCode) && (i.message = d + " " + i.message, i.errMsg = i.message), i;
                                    case 4:
                                        return t = void 0, [7];
                                    case 5:
                                        return [2]
                                }
                            })
                        })
                    }
                }(e)
            }
        }
    }
    n.d(t, "a", function() { return _ });
    var p = "web";

    function _(e) { var t = { name: p, identifiers: e.identifiers, request: e.request, isInstance: e.isInstance, get debug() { return e.debug }, get env() { return e.getEnvForService(p) }, cloud: e, appConfig: {} }; return { name: p, context: t, getAPIs: h.bind(null, t) } }
}, function(e, t, n) {
    "use strict";
    t.a = function(e, t) {
        var n = -1,
            r = e.length;
        for (t || (t = Array(r)); ++n < r;) t[n] = e[n];
        return t
    }
}, function(e, t, n) {
    "use strict";
    (function(e) {
        var n = "object" == typeof e && e && e.Object === Object && e;
        t.a = n
    }).call(this, n(32))
}, function(e, t, n) {
    "use strict";
    (function(e) {
        var r = n(11),
            i = "object" == typeof exports && exports && !exports.nodeType && exports,
            o = i && "object" == typeof e && e && !e.nodeType && e,
            a = o && o.exports === i ? r.a.Buffer : void 0,
            s = a ? a.allocUnsafe : void 0;
        t.a = function(e, t) {
            if (t) return e.slice();
            var n = e.length,
                r = s ? s(n) : new e.constructor(n);
            return e.copy(r), r
        }
    }).call(this, n(62)(e))
}, function(e, t, n) {
    "use strict";
    t.a = function(e, t) { return function(n) { return e(t(n)) } }
}, function(e, t, n) {
    "use strict";
    var r = 9007199254740991;
    t.a = function(e) { return "number" == typeof e && e > -1 && e % 1 == 0 && e <= r }
}, function(e, t, n) {
    "use strict";
    var r = n(41);
    t.a = function(e, t) { var n = t ? Object(r.a)(e.buffer) : e.buffer; return new e.constructor(n, e.byteOffset, e.length) }
}, function(e, t, n) {
    "use strict";
    var r = n(27);
    var i = function() { this.__data__ = new r.a, this.size = 0 };
    var o = function(e) {
        var t = this.__data__,
            n = t.delete(e);
        return this.size = t.size, n
    };
    var a = function(e) { return this.__data__.get(e) };
    var s = function(e) { return this.__data__.has(e) },
        u = n(29),
        c = n(46),
        f = 200;
    var l = function(e, t) {
        var n = this.__data__;
        if (n instanceof r.a) {
            var i = n.__data__;
            if (!u.a || i.length < f - 1) return i.push([e, t]), this.size = ++n.size, this;
            n = this.__data__ = new c.a(i)
        }
        return n.set(e, t), this.size = n.size, this
    };

    function d(e) {
        var t = this.__data__ = new r.a(e);
        this.size = t.size
    }
    d.prototype.clear = i, d.prototype.delete = o, d.prototype.get = a, d.prototype.has = s, d.prototype.set = l;
    t.a = d
}, function(e, t, n) {
    "use strict";
    var r = n(19),
        i = n(55),
        o = n(14),
        a = {};
    a["[object Float32Array]"] = a["[object Float64Array]"] = a["[object Int8Array]"] = a["[object Int16Array]"] = a["[object Int32Array]"] = a["[object Uint8Array]"] = a["[object Uint8ClampedArray]"] = a["[object Uint16Array]"] = a["[object Uint32Array]"] = !0, a["[object Arguments]"] = a["[object Array]"] = a["[object ArrayBuffer]"] = a["[object Boolean]"] = a["[object DataView]"] = a["[object Date]"] = a["[object Error]"] = a["[object Function]"] = a["[object Map]"] = a["[object Number]"] = a["[object Object]"] = a["[object RegExp]"] = a["[object Set]"] = a["[object String]"] = a["[object WeakMap]"] = !1;
    var s = function(e) { return Object(o.a)(e) && Object(i.a)(e.length) && !!a[Object(r.a)(e)] },
        u = n(39),
        c = n(23),
        f = c.a && c.a.isTypedArray,
        l = f ? Object(u.a)(f) : s;
    t.a = l
}, function(e, t, n) {
    "use strict";
    var r = n(12),
        i = Object.create,
        o = function() {
            function e() {}
            return function(t) {
                if (!Object(r.a)(t)) return {};
                if (i) return i(t);
                e.prototype = t;
                var n = new e;
                return e.prototype = void 0, n
            }
        }(),
        a = n(36),
        s = n(35);
    t.a = function(e) { return "function" != typeof e.constructor || Object(s.a)(e) ? {} : o(Object(a.a)(e)) }
}, function(e, t, n) {
    "use strict";
    var r = function(e, t) { for (var n = -1, r = Array(e); ++n < e;) r[n] = t(n); return r },
        i = n(47),
        o = n(16),
        a = n(34),
        s = n(40),
        u = n(58),
        c = Object.prototype.hasOwnProperty;
    t.a = function(e, t) {
        var n = Object(o.a)(e),
            f = !n && Object(i.a)(e),
            l = !n && !f && Object(a.a)(e),
            d = !n && !f && !l && Object(u.a)(e),
            h = n || f || l || d,
            p = h ? r(e.length, String) : [],
            _ = p.length;
        for (var b in e) !t && !c.call(e, b) || h && ("length" == b || l && ("offset" == b || "parent" == b) || d && ("buffer" == b || "byteLength" == b || "byteOffset" == b) || Object(s.a)(b, _)) || p.push(b);
        return p
    }
}, function(e, t) {
    var n, r, i = e.exports = {};

    function o() { throw new Error("setTimeout has not been defined") }

    function a() { throw new Error("clearTimeout has not been defined") }

    function s(e) { if (n === setTimeout) return setTimeout(e, 0); if ((n === o || !n) && setTimeout) return n = setTimeout, setTimeout(e, 0); try { return n(e, 0) } catch (t) { try { return n.call(null, e, 0) } catch (t) { return n.call(this, e, 0) } } }! function() { try { n = "function" == typeof setTimeout ? setTimeout : o } catch (e) { n = o } try { r = "function" == typeof clearTimeout ? clearTimeout : a } catch (e) { r = a } }();
    var u, c = [],
        f = !1,
        l = -1;

    function d() { f && u && (f = !1, u.length ? c = u.concat(c) : l = -1, c.length && h()) }

    function h() {
        if (!f) {
            var e = s(d);
            f = !0;
            for (var t = c.length; t;) {
                for (u = c, c = []; ++l < t;) u && u[l].run();
                l = -1, t = c.length
            }
            u = null, f = !1,
                function(e) { if (r === clearTimeout) return clearTimeout(e); if ((r === a || !r) && clearTimeout) return r = clearTimeout, clearTimeout(e); try { r(e) } catch (t) { try { return r.call(null, e) } catch (t) { return r.call(this, e) } } }(e)
        }
    }

    function p(e, t) { this.fun = e, this.array = t }

    function _() {}
    i.nextTick = function(e) {
        var t = new Array(arguments.length - 1);
        if (arguments.length > 1)
            for (var n = 1; n < arguments.length; n++) t[n - 1] = arguments[n];
        c.push(new p(e, t)), 1 !== c.length || f || s(h)
    }, p.prototype.run = function() { this.fun.apply(null, this.array) }, i.title = "browser", i.browser = !0, i.env = {}, i.argv = [], i.version = "", i.versions = {}, i.on = _, i.addListener = _, i.once = _, i.off = _, i.removeListener = _, i.removeAllListeners = _, i.emit = _, i.prependListener = _, i.prependOnceListener = _, i.listeners = function(e) { return [] }, i.binding = function(e) { throw new Error("process.binding is not supported") }, i.cwd = function() { return "/" }, i.chdir = function(e) { throw new Error("process.chdir is not supported") }, i.umask = function() { return 0 }
}, function(e, t) {
    e.exports = function(e) {
        if (!e.webpackPolyfill) {
            var t = Object.create(e);
            t.children || (t.children = []), Object.defineProperty(t, "loaded", { enumerable: !0, get: function() { return t.l } }), Object.defineProperty(t, "id", { enumerable: !0, get: function() { return t.i } }), Object.defineProperty(t, "exports", { enumerable: !0 }), t.webpackPolyfill = 1
        }
        return t
    }
}, function(e, t, n) {
    "use strict";
    var r = n(57),
        i = n(37),
        o = n(25);
    var a = function(e, t, n) {
        (void 0 === n || Object(o.a)(e[t], n)) && (void 0 !== n || t in e) || Object(i.a)(e, t, n)
    };
    var s = function(e) { return function(t, n, r) { for (var i = -1, o = Object(t), a = r(t), s = a.length; s--;) { var u = a[e ? s : ++i]; if (!1 === n(o[u], u, o)) break } return t } }(),
        u = n(53),
        c = n(56),
        f = n(51),
        l = n(59),
        d = n(47),
        h = n(16),
        p = n(26),
        _ = n(14);
    var b = function(e) { return Object(_.a)(e) && Object(p.a)(e) },
        g = n(34),
        E = n(33),
        O = n(12),
        y = n(19),
        m = n(36),
        T = "[object Object]",
        v = Function.prototype,
        S = Object.prototype,
        N = v.toString,
        I = S.hasOwnProperty,
        A = N.call(Object);
    var w = function(e) { if (!Object(_.a)(e) || Object(y.a)(e) != T) return !1; var t = Object(m.a)(e); if (null === t) return !0; var n = I.call(t, "constructor") && t.constructor; return "function" == typeof n && n instanceof n && N.call(n) == A },
        R = n(58);
    var C = function(e, t) { if (("constructor" !== t || "function" != typeof e[t]) && "__proto__" != t) return e[t] },
        D = n(21),
        B = n(28);
    var L = function(e) { return Object(D.a)(e, Object(B.a)(e)) };
    var j = function(e, t, n, r, i, o, s) {
        var p = C(e, n),
            _ = C(t, n),
            y = s.get(_);
        if (y) a(e, n, y);
        else {
            var m = o ? o(p, _, n + "", e, t, s) : void 0,
                T = void 0 === m;
            if (T) {
                var v = Object(h.a)(_),
                    S = !v && Object(g.a)(_),
                    N = !v && !S && Object(R.a)(_);
                m = _, v || S || N ? Object(h.a)(p) ? m = p : b(p) ? m = Object(f.a)(p) : S ? (T = !1, m = Object(u.a)(_, !0)) : N ? (T = !1, m = Object(c.a)(_, !0)) : m = [] : w(_) || Object(d.a)(_) ? (m = p, Object(d.a)(p) ? m = L(p) : Object(O.a)(p) && !Object(E.a)(p) || (m = Object(l.a)(_))) : T = !1
            }
            T && (s.set(_, m), i(m, _, r, o, s), s.delete(_)), a(e, n, m)
        }
    };
    var P = function e(t, n, i, o, u) {
        t !== n && s(n, function(s, c) {
            if (u || (u = new r.a), Object(O.a)(s)) j(t, n, c, i, e, o, u);
            else {
                var f = o ? o(C(t, c), s, c + "", t, n, u) : void 0;
                void 0 === f && (f = s), a(t, c, f)
            }
        }, B.a)
    };
    var M = function(e) { return e };
    var U = function(e, t, n) {
            switch (n.length) {
                case 0:
                    return e.call(t);
                case 1:
                    return e.call(t, n[0]);
                case 2:
                    return e.call(t, n[0], n[1]);
                case 3:
                    return e.call(t, n[0], n[1], n[2])
            }
            return e.apply(t, n)
        },
        x = Math.max;
    var $ = function(e, t, n) {
        return t = x(void 0 === t ? e.length - 1 : t, 0),
            function() {
                for (var r = arguments, i = -1, o = x(r.length - t, 0), a = Array(o); ++i < o;) a[i] = r[t + i];
                i = -1;
                for (var s = Array(t + 1); ++i < t;) s[i] = r[i];
                return s[t] = n(a), U(e, this, s)
            }
    };
    var k = function(e) { return function() { return e } },
        F = n(42),
        W = F.a ? function(e, t) { return Object(F.a)(e, "toString", { configurable: !0, enumerable: !1, value: k(t), writable: !0 }) } : M,
        q = 800,
        z = 16,
        Y = Date.now;
    var G = function(e) {
        var t = 0,
            n = 0;
        return function() {
            var r = Y(),
                i = z - (r - n);
            if (n = r, i > 0) { if (++t >= q) return arguments[0] } else t = 0;
            return e.apply(void 0, arguments)
        }
    }(W);
    var H = function(e, t) { return G($(e, t, M), e + "") },
        K = n(40);
    var V = function(e, t, n) { if (!Object(O.a)(n)) return !1; var r = typeof t; return !!("number" == r ? Object(p.a)(n) && Object(K.a)(t, n.length) : "string" == r && t in n) && Object(o.a)(n[t], e) };
    var X = function(e) {
        return H(function(t, n) {
            var r = -1,
                i = n.length,
                o = i > 1 ? n[i - 1] : void 0,
                a = i > 2 ? n[2] : void 0;
            for (o = e.length > 3 && "function" == typeof o ? (i--, o) : void 0, a && V(n[0], n[1], a) && (o = i < 3 ? void 0 : o, i = 1), t = Object(t); ++r < i;) {
                var s = n[r];
                s && e(t, s, r, o)
            }
            return t
        })
    }(function(e, t, n) { P(e, t, n) });
    t.a = X
}, function(e, t, n) {
    "use strict";
    (function(e) {
        n.d(t, "a", function() { return g });
        var r = n(0),
            i = n(63),
            o = n(67),
            a = n(44),
            s = n(1),
            u = n(2),
            c = n(43),
            f = n(3),
            l = n(9),
            d = n(8),
            h = n(4),
            p = n(48),
            _ = n(45),
            b = n(66),
            g = function(e) {
                void 0 === e && (e = {});
                var t = e.sdk,
                    n = e.identifiers || {};
                return t && Object(l.c)(n, t), new E(n, !1)
            },
            E = function() {
                function t(t, n) {
                    var i = this;
                    this.inited = !1, this.services = {}, this.apiServiceMap = {}, this.debug = !1, this.testSpeed = function() { return Object(r.b)(i, void 0, void 0, function() { var e, t, n; return Object(r.d)(this, function(r) { return e = +new Date, t = e, n = Object(c.a)({ cloud: this, apiName: "tcbapi_testspeed", serializedReqData: null }), [2, Object(c.d)(n, { fireOnIdle: !0, onFire: function() { e = +new Date, t = e } }).then(function(n) { Object(h.b)({ apiName: "cloud.testspeed", apiEndTime: +new Date, apiStartTime: e, tunnelEndTime: +new Date, tunnelStartTime: t, tunnelTimeNoCSNetCost: n.data.baseresponse.stat.qbase_cost_time }) }).catch(function(e) { 0 })] }) }) }, this.identifiers = t, this.isInstance = n, this.runtimeInfo = Object(_.a)(), this.serviceEndpoint = new b.a, this.request = Object(c.c)({ cloud: this });
                    var a = this;
                    this.exportAPI = { init: this.init.bind(this) }, this.isInstance || (this.exportAPI.Cloud = function(e) { return new O(t, a, e).exportAPI }), Object(o.a)(this), this.meta = { session_id: Date.now() + "" }, this.serviceEndpoint.setMetaData(this.getMetaData()), this.serviceEndpoint.setTunnelRequest(this.request), this.config = { database: y() }, this.appConfig = Object(r.a)({}, p.b), this.apiPermissions = {};
                    try { d.a.onReady(function() { setTimeout(function() { Object(h.a)() }, 2e3) }), e.env.TEST && (this.exportAPI.getCloudInstance = function() { return i }) } catch (e) {}
                }
                return t.prototype.getMetaData = function() {
                    var e;
                    if (!this.meta.sdk_version) {
                        var t = Object(l.a)(this.identifiers);
                        if (t) {
                            var n = t.wx;
                            n && n.version && ("miniprogram" === this.runtimeInfo.env ? this.meta.sdk_version = "wx-miniprogram-sdk/" + n.version.version + " (" + Date.parse(n.version.updateTime + " GMT+0800") + ")" : this.meta.sdk_version = "wx-web-sdk/1.1.0 (" + Date.parse("2020.10.12 12:11:43 GMT+0800") + ")")
                        }
                    }
                    return this.meta.filter_user_info = "singlePage" === (null === (e = d.a.appLaunchInfo) || void 0 === e ? void 0 : e.mode), this.meta
                }, t.prototype.getConfig = function() { return this.config }, t.prototype.getEnvForService = function(e) {
                    if (this.isInstance) return this.instanceOptions.resourceEnv;
                    var t = this.config;
                    if (t.env) switch (Object(u.a)(t.env)) {
                        case "string":
                            return t.env;
                        case "object":
                            return t.env[e];
                        default:
                            return
                    }
                }, t.prototype.checkAPIPermission = function(e) { return !this.apiPermissions.hasOwnProperty(e) || 1 === this.apiPermissions[e] }, t.prototype.init = function(e) { var t = this; return void 0 === e && (e = {}), this.inited = !0, this.initConfig(e), this.sendInitRequest().then(function() { t.testSpeed() }) }, t.prototype.initConfig = function(e) { this.config = JSON.parse(JSON.stringify(e)), this.config.database ? this.config.database = Object(i.a)(this.config.database, y()) : this.config.database = y() }, t.prototype.sendInitRequest = function() {
                    var e = this,
                        t = JSON.stringify({ trace_user: !1 !== this.config.traceUser, env: "string" == typeof this.config.env ? this.config.env : void 0 }),
                        n = +new Date,
                        i = n;
                    return this.request({ apiName: "tcbapi_init", serializedReqData: t }).then(function(t) {
                        var o = +new Date,
                            a = t.data;
                        e.appConfig = Object(r.a)(Object(r.a)({}, e.appConfig), a.config);
                        for (var s = a.tcb_api_list || [], u = 0, c = s.length; u < c; u++) e.apiPermissions[s[u].apiname] = s[u].status;
                        Object(h.b)({ apiName: "cloud.init", apiEndTime: +new Date, apiStartTime: n, tunnelEndTime: o, tunnelStartTime: i, tunnelTimeNoCSNetCost: a.baseresponse.stat.qbase_cost_time })
                    }).catch(function(e) { console.error("cloud init error: ", e) })
                }, t.prototype.registerService = function(e) {
                    this.services[e.name] = e;
                    var t = e.getAPIs();
                    for (var n in t)
                        if (this.apiServiceMap[n] = e.name, "function" == typeof t[n]) this.registerFunction(n, !0, t[n]);
                        else {
                            var r = t[n],
                                i = r.initRequired,
                                o = r.fn;
                            this.registerFunction(n, i, o)
                        }
                }, t.prototype.registerFunction = function(e, t, n) {
                    var r = this;
                    this.exportAPI[e] = t ? function() { if (!r.inited) throw new s.b({ errMsg: "Cloud API isn't enabled, please call wx.cloud.init first\n璇峰厛璋冪敤 wx.cloud.init() 瀹屾垚鍒濆鍖栧悗鍐嶈皟鐢ㄥ叾浠栦簯 API銆�" }); if (!r.checkAPIPermission(e)) throw new s.b({ errCode: f.a.SDK_API_PERMISSION_DENIED, errMsg: f.a[f.a.SDK_API_PERMISSION_DENIED] }); return n.apply(r, arguments) } : n
                }, t.prototype.toJSON = function() {}, t
            }(),
            O = function(e) {
                function t(t, n, r) { var o = e.call(this, t, !0) || this; if ("web" === o.runtimeInfo.env) { if (!r.identityless && !r.appid) throw new Error("appid must be provided"); if (!r.resourceAppid) throw new Error("resourceAppid must be provided") } if (!r.resourceEnv) throw new Error("resourceEnv must be provided"); if (r.config || (r.config = {}), o.defaultInstance = n, o.instanceOptions = JSON.parse(JSON.stringify(r)), o.meta = n.meta, o.apiPermissions = n.apiPermissions, o.instanceOptions.config.database = Object(i.a)(y(), o.instanceOptions.config.database || {}), "web" === o.runtimeInfo.env) { if (o.exportAPI.init = o.webInit.bind(o), o.webRequest = Object(a.b)(o), o.registerService(Object(a.a)(o)), !o.instanceOptions.identityless && (o.authStorage = o.defaultInstance.authStorage, !o.authStorage)) throw new Error("authStorage not found") } else o.exportAPI.init = o.miniprogramInit.bind(o); return o.instanceOptions.resourceAppid && (o.exportAPI.refreshAuth = o.refreshAuth.bind(o)), o }
                return Object(r.c)(t, e), t.prototype.miniprogramInit = function() {
                    return Object(r.b)(this, void 0, void 0, function() {
                        var t, n;
                        return Object(r.d)(this, function(r) {
                            switch (r.label) {
                                case 0:
                                    return this.inited ? [2] : this.instanceOptions.resourceAppid ? [4, this.refreshAuth()] : [3, 2];
                                case 1:
                                    return t = r.sent(), 0 === (n = t.data.env_auth_info).errCode ? (e.prototype.init.call(this), [2, { errCode: n.errCode, errMsg: n.errMsg, expireTime: 1e3 * n.expire_time }]) : [2, { errCode: n.errCode, errMsg: n.errMsg }];
                                case 2:
                                    return e.prototype.init.call(this), [2]
                            }
                        })
                    })
                }, t.prototype.webInit = function() {
                    return Object(r.b)(this, void 0, void 0, function() {
                        var t, n, i = this;
                        return Object(r.d)(this, function(r) {
                            switch (r.label) {
                                case 0:
                                    return this.inited ? [2] : this.instanceOptions.identityless ? [3, 2] : [4, this.refreshAuth()];
                                case 1:
                                    return t = r.sent(), 0 === (n = t.data.env_auth_info).errCode ? (this.sendInitRequest().then(function() { i.testSpeed() }), e.prototype.init.call(this), [2, { errCode: n.errCode, errMsg: n.errMsg, expireTime: 1e3 * n.expire_time }]) : [2, { errCode: n.errCode, errMsg: n.errMsg }];
                                case 2:
                                    return this.inited = !0, [2]
                            }
                        })
                    })
                }, t.prototype.webRefreshToken = function() {
                    return Object(r.b)(this, void 0, void 0, function() {
                        var e = this;
                        return Object(r.d)(this, function(t) {
                            return this._webCurrentRefreshTokenPromise ? [2, this._webCurrentRefreshTokenPromise] : (this._webCurrentRefreshTokenPromise = new Promise(function(t, n) {
                                return Object(r.b)(e, void 0, void 0, function() {
                                    var e, i, o;
                                    return Object(r.d)(this, function(r) {
                                        switch (r.label) {
                                            case 0:
                                                return r.trys.push([0, 2, 3, 4]), [4, this.webRequest({ url: "https://servicewechat.com/wxa-qbase/refresh_token", method: "POST", json: { appid: this.instanceOptions.appid, refresh_token: this.authStorage.getItem("refreshToken") } })];
                                            case 1:
                                                return e = r.sent(), i = e.data, this.authStorage.setItem("appid", i.access_token), t(), [3, 4];
                                            case 2:
                                                return o = r.sent(), n(o), [3, 4];
                                            case 3:
                                                return this._webCurrentRefreshTokenPromise = void 0, [7];
                                            case 4:
                                                return [2]
                                        }
                                    })
                                })
                            }), [2, this._webCurrentRefreshTokenPromise])
                        })
                    })
                }, t.prototype.refreshAuth = function() {
                    var e = JSON.stringify({ resource_appid: this.instanceOptions.resourceAppid, resource_env: this.instanceOptions.resourceEnv }),
                        t = +new Date,
                        n = t,
                        r = this.request({ apiName: "tcbapi_getenvauth", serializedReqData: e });
                    return r.then(function(e) {
                        var r = +new Date;
                        Object(h.b)({ apiName: "cloud.refreshAuth", apiEndTime: +new Date, apiStartTime: t, tunnelEndTime: r, tunnelStartTime: n })
                    }), r
                }, t
            }(E);

        function y() { return { realtime: { maxReconnect: p.a.REALTIME_DB_MAX_RECONNECT, reconnectInterval: p.a.REALTIME_DB_WS_RECONNECT_INTERVAL, totalConnectionTimeout: p.a.REALTIME_DB_TOTAL_CONNECTION_TIMEOUT } } }
    }).call(this, n(61))
}, function(e, t, n) {
    "use strict";
    t.a = function() { return !1 }
}, function(e, t, n) {
    "use strict";
    n.d(t, "a", function() { return u });
    var r = n(0),
        i = n(43),
        o = {},
        a = {},
        s = {},
        u = function() {
            function e() {}
            return e.prototype.setMetaData = function(e) { this._meta = e }, e.prototype.setTunnelRequest = function(e) { this._tunnelRequest = e }, e.prototype.getEndpoint = function(e) { return Object(r.b)(this, void 0, void 0, function() { var t; return Object(r.d)(this, function(n) { return (null === (t = o[e]) || void 0 === t ? void 0 : t.url) && (null === t || void 0 === t ? void 0 : t.expiresTs) && Date.now() < t.expiresTs ? [2, t] : [2, this.refreshContainerServiceEndpoint()] }) }) }, e.prototype.refreshContainerServiceEndpoint = function() {
                return Object(r.b)(this, void 0, void 0, function() {
                    var e = this;
                    return Object(r.d)(this, function(t) {
                        return a.container ? [2, a.container] : (clearTimeout(s.container), a.container = new Promise(function(t, n) {
                            return Object(r.b)(e, void 0, void 0, function() {
                                var e, u, c, f, l, d, h, p = this;
                                return Object(r.d)(this, function(r) {
                                    switch (r.label) {
                                        case 0:
                                            e = [], u = 0, r.label = 1;
                                        case 1:
                                            if (!(u < 3)) return [3, 9];
                                            r.label = 2;
                                        case 2:
                                            return r.trys.push([2, 7, , 8]), c = Date.now(), this._tunnelRequest ? [4, this._tunnelRequest({ apiName: "tcbapi_get_service_info", serializedReqData: "{}" })] : [3, 4];
                                        case 3:
                                            return f = r.sent(), [3, 6];
                                        case 4:
                                            return [4, Object(i.b)({ apiName: "qbase_commapi", data: { qbase_api_name: "tcbapi_get_service_info", qbase_req: "{}", qbase_options: {}, qbase_meta: this._meta, cli_req_id: +new Date + "_" + Math.random() } })];
                                        case 5:
                                            f = r.sent(), r.label = 6;
                                        case 6:
                                            return l = f.data, Date.now() - c > 1e3 * l.expires_in ? (e.push("result already expired (startTs " + c + " resultTs " + Date.now() + ")"), [3, 8]) : (d = Date.now() + 1e3 * l.expires_in - (Date.now() - c), o.container = { url: l.service_url, expiresTs: d }, t(o.container), delete a.container, s.container = setTimeout(function() { p.refreshContainerServiceEndpoint() }, .8 * (d - Date.now())), [2]);
                                        case 7:
                                            return h = r.sent(), e.push(h + ""), [3, 8];
                                        case 8:
                                            return u++, [3, 1];
                                        case 9:
                                            return n("get container service endpoints errors: " + e.join("\n")), delete a.container, [2]
                                    }
                                })
                            })
                        }), [2, a.container])
                    })
                })
            }, e
        }()
}, function(e, t, n) {
    "use strict";
    var r = {};
    n.r(r), n.d(r, "__safe_props__", function() { return yt }), n.d(r, "Point", function() { return ot }), n.d(r, "GeoPoint", function() { return at }), n.d(r, "MultiPoint", function() { return st }), n.d(r, "GeoMultiPoint", function() { return ut }), n.d(r, "LineString", function() { return ct }), n.d(r, "GeoLineString", function() { return ft }), n.d(r, "MultiLineString", function() { return lt }), n.d(r, "GeoMultiLineString", function() { return dt }), n.d(r, "Polygon", function() { return ht }), n.d(r, "GeoPolygon", function() { return pt }), n.d(r, "MultiPolygon", function() { return _t }), n.d(r, "GeoMultiPolygon", function() { return bt });
    var i = {};
    n.r(i), n.d(i, "extractQueryOptions", function() { return Gt }), n.d(i, "getProjectionDefinition", function() { return Ht }), n.d(i, "OperatorMap", function() { return lo }), n.d(i, "AggregateOperatorMap", function() { return ho }), n.d(i, "operatorToString", function() { return _o }), n.d(i, "aggregateOperatorToString", function() { return bo }), n.d(i, "QuerySerializer", function() { return yo }), n.d(i, "encode", function() { return mo }), n.d(i, "UpdateSerializer", function() { return Io }), n.d(i, "ProjectionSerializer", function() { return Ro }), n.d(i, "Decoder", function() { return Co }), n.d(i, "AggregateSerializer", function() { return Eo }), n.d(i, "flattenQueryObject", function() { return kt }), n.d(i, "flattenObject", function() { return Ft }), n.d(i, "mergeConditionAfterEncode", function() { return Wt }), n.d(i, "isConversionRequired", function() { return qt }), n.d(i, "encodeInternalDataType", function() { return zt }), n.d(i, "decodeInternalDataType", function() { return Yt });
    var o = n(0),
        a = n(6),
        s = n(5),
        u = n(1),
        c = n(22),
        f = n(2);

    function l(e, t) {
        if (void 0 === t && (t = !1), t) return function(e) {
            switch (Object(f.a)(e)) {
                case "object":
                    return Object(o.a)({}, e);
                case "array":
                    return e.slice();
                case "number":
                    return e instanceof Number ? new Number(e) : e;
                case "string":
                    return e instanceof String ? new String(e) : e;
                case "boolean":
                    return e instanceof Boolean ? new Boolean(e) : e;
                case "date":
                    return new e.constructor(+e);
                case "map":
                    return new Map(e);
                case "set":
                    return new Set(e);
                default:
                    return e
            }
        }(e);
        if (Object(f.h)(e)) return Object(o.a)({}, e);
        switch (Object(f.a)(e)) {
            case "object":
                return e;
            case "array":
                return e.slice();
            default:
                return e
        }
    }
    var d = n(4),
        h = n(8),
        p = n(10),
        _ = n(3);

    function b(e, t) {
        return JSON.stringify(e, function(e, n) {
            if (t && t.has(n)) return t.get(n);
            switch (Object(f.a)(n)) {
                case "arraybuffer":
                    var r = new Uint8Array(n);
                    return { type: "Buffer", data: Object(o.f)(r) }
            }
            return n
        })
    }

    function g(e) { return E(JSON.parse(e)) }

    function E(e) {
        switch (Object(f.a)(e)) {
            case "object":
                return function e(t) {
                    var n = t;
                    var r = O(n);
                    if (n !== r) return r;
                    for (var i in n) {
                        var o = n[i],
                            a = Object(f.a)(o);
                        switch (a) {
                            case "object":
                                var s = O(o);
                                n[i] = s !== o ? s : e(n[i]);
                                break;
                            case "array":
                                var s = E(o);
                                s !== o && (n[i] = s);
                                break;
                            default:
                                continue
                        }
                    }
                    return n
                }(e);
            case "array":
                return e.map(E);
            default:
                return e
        }
    }

    function O(e) {
        for (var t in e) switch (t) {
            case "type":
                switch (e.type) {
                    case "Buffer":
                        if (Object(f.b)(e.data) && Object(f.f)(e.data[0])) try { return new Uint8Array(e.data).buffer } catch (t) { return e }
                }
        }
        return e
    }
    var y = n(9),
        m = Symbol.for("CLOUD_ID"),
        T = Symbol("CDN");

    function v(e) { var t = []; for (var n in e) Object(f.g)(e[n]) && e[n]._internalType === m && t.push({ key: n, cloudID: e[n].cloudID }); return t }

    function S(e) {
        return function(t) {
            return Object(o.b)(this, void 0, void 0, function() {
                function n(t) {
                    return Object(o.b)(this, void 0, void 0, function() {
                        return Object(o.d)(this, function(n) {
                            return [2, new Promise(function(n, r) {
                                ! function t(n, r, i, a) {
                                    return Object(o.b)(this, void 0, void 0, function() {
                                        return Object(o.d)(this, function(o) {
                                            return Object(y.a)(e.identifiers)._requestSkipCheckDomain({
                                                url: n,
                                                success: function(e) {
                                                    try {
                                                        if (200 !== e.statusCode) return a(Object(u.g)({ errCode: _.a.SDK_FUNCTIONS_POLL_RESULT_STATUS_CODE_ERROR, errMsg: "polling status code " + e.statusCode }, k));
                                                        var o = e.data;
                                                        if (!o) return a(Object(u.g)({ errCode: _.a.SDK_FUNCTIONS_EMPTY_POLL_RESULT_JSON, errMsg: _.a[_.a.SDK_FUNCTIONS_EMPTY_POLL_RESULT_JSON] }, k));
                                                        if (o.base_resp && 0 === o.base_resp.ret) {
                                                            if (0 !== o.status) { if (1 === o.status) { if (0 !== o.service_errcode) { var s = Object(u.g)({ errCode: _.a.SDK_FUNCTIONS_CLOUD_FUNCTION_EXECUTION_ERROR, errMsg: "requestID " + o.func_req_id + ", cloud function service error code " + (o.service_errcode || "unknown") + ", error message " + (o.service_errmsg || "unknown") }, k); return s.requestID = o.func_req_id, a(s) } var c = o.content; try { c = g(c) } catch (e) { try { c = JSON.parse(c) } catch (e) {} } return i({ result: c, requestID: o.func_req_id }) } return a(Object(u.g)({ errCode: _.a.SDK_FUNCTIONS_POLL_RESULT_EXPIRED, errMsg: "timeout for result fetching" }, k)) }
                                                            if (!(r >= 0)) return a(Object(u.g)({ errCode: _.a.SDK_FUNCTIONS_EXCEED_MAX_POLL_RETRY, errMsg: _.a[_.a.SDK_FUNCTIONS_EXCEED_MAX_POLL_RETRY] }, k));
                                                            t(n, r - 1, i, a)
                                                        } else { if (!o.base_resp) return a(Object(u.g)({ errCode: _.a.SDK_FUNCTIONS_EMPTY_POLL_RESULT_BASE_RESP, errMsg: _.a[_.a.SDK_FUNCTIONS_EMPTY_POLL_RESULT_BASE_RESP] }, k)); if (0 !== o.base_resp.ret) return a(Object(u.g)({ errCode: _.a.SDK_FUNCTIONS_POLL_RESULT_BASE_RESP_RET_ABNORMAL, errMsg: "polling base_resp.ret " + o.base_resp.ret }, k)) }
                                                    } catch (e) { a(Object(u.g)({ errCode: _.a.SDK_FUNCTIONS_POLL_ERROR, errMsg: "polling catch error: " + e }, k)) }
                                                },
                                                fail: function(e) { a(Object(u.g)(e, k)) }
                                            }), [2]
                                        })
                                    })
                                }(t, e.appConfig.maxPollRetry || 50, n, r)
                            })]
                        })
                    })
                }
                var r, i, a, c, f, l, d, h, E, O, m, T, S, N, I, A;
                return Object(o.d)(this, function(g) {
                    switch (g.label) {
                        case 0:
                            if (r = Object(o.a)({}, t.data), (i = v(r).map(function(e) { return { key_name: e.key, cloud_id: e.cloudID } })).length) try { for (a = Object(o.g)(i), c = a.next(); !c.done; c = a.next()) f = c.value, delete r[f.key_name] } catch (e) { I = { error: e } } finally { try { c && !c.done && (A = a.return) && A.call(a) } finally { if (I) throw I.error } }
                            return [4, t.cdnMapPromise];
                        case 1:
                            return l = g.sent(), d = b(r, l), Object(s.c)({ input: d, max: e.appConfig.maxReqDataSize, name: "callFunction data", maxWording: e.appConfig.maxReqDataSize / 1024 + " KB" }), h = { function_name: t.name, data: d, cloudid_list: i }, E = b(h), t.context.tunnelStartTime = +new Date, [4, e.request({ apiName: "tcbapi_slowcallfunction", serviceName: e.name, serializedReqData: E, env: t.config && t.config.env || e.env })];
                        case 2:
                            if (O = g.sent(), t.context.tunnelEndTime = +new Date, !(m = O.data)) throw Object(u.g)({ errCode: _.a.SDK_FUNCTIONS_EMPTY_CALL_RESULT, errMsg: _.a[_.a.SDK_FUNCTIONS_EMPTY_CALL_RESULT] }, k);
                            if (m.event_id, !m.poll_url) throw Object(u.g)({ errCode: _.a.SDK_FUNCTIONS_EMPTY_POLL_URL, errMsg: _.a[_.a.SDK_FUNCTIONS_EMPTY_POLL_URL] }, k);
                            return m.poll_url.indexOf("?") > -1 ? m.poll_url += "&devtools_ignore=true&skip_domain_check=true" : m.poll_url += "?devtools_ignore=true&skip_domain_check=true", t.context.pollStartTime = +new Date, [4, n(m.poll_url)];
                        case 3:
                            return T = g.sent(), S = T.result, N = T.requestID, t.context.pollEndTime = +new Date, [2, { errMsg: Object(p.b)(k), result: S, requestID: N }]
                    }
                })
            })
        }
    }
    var N = n(13),
        I = 50,
        A = 2,
        w = 2,
        R = 2e4,
        C = function(e) { var t = new Date; return t.getHours() + ":" + t.getMinutes() + ":" + t.getSeconds() + " " + e },
        D = function(e) { return e.join("->") };

    function B(e) {
        return function(t) {
            return Object(o.b)(this, void 0, void 0, function() {
                function n(t, n, i, a) {
                    return Object(o.b)(this, void 0, void 0, function() {
                        return Object(o.d)(this, function(o) {
                            return [2, new Promise(function(o, s) {
                                var u = [C("start")],
                                    c = function(e, t, n) { var r = function(t) { e.push(C("app " + t)) }; return Object(N.d)(r), { resolve: function(e) { Object(N.c)(r), t(e) }, reject: function(e) { Object(N.c)(r), n(e) } } }(u, o, s),
                                    f = c.resolve,
                                    l = c.reject;
                                r({ param: t, functionName: t.name, data: n, cloudIDList: i, callID: a, action: j.CALL, scene: P.INITIATE_CALL, tryCount: e.appConfig.maxPollRetry || I, systemErrorRetry: A, timeoutErrorRetry: w, trace: u, resolve: f, reject: l })
                            })]
                        })
                    })
                }

                function r(n) {
                    return Object(o.b)(this, void 0, void 0, function() {
                        function i(e) {
                            try {
                                if (I) return;
                                w(), M(e);
                                var t = e.data;
                                if (!t) return E.push(C("empty resp")), T(Object(u.g)({ errCode: _.a.SDK_FUNCTIONS_EMPTY_CALL_RESULT, errMsg: _.a[_.a.SDK_FUNCTIONS_EMPTY_CALL_RESULT] }, k));
                                if (!t.baseresponse || 0 !== t.baseresponse.errcode) return t.baseresponse ? 0 !== t.baseresponse.errcode ? T(Object(u.g)({ errCode: _.a.SDK_FUNCTIONS_POLL_RESULT_BASE_RESP_RET_ABNORMAL, errMsg: "polling base_resp.errcode " + t.baseresponse.errcode + " errmsg " + t.baseresponse.errmsg + " (callId: " + f + ")" }, k)) : T(Object(u.g)({ errCode: _.a.SDK_FUNCTIONS_EMPTY_POLL_RESULT_BASE_RESP, errMsg: "polling base_resp " + JSON.stringify(t.baseresponse) + " (callId: " + f + ")" }, k)) : T(Object(u.g)({ errCode: _.a.SDK_FUNCTIONS_EMPTY_POLL_RESULT_BASE_RESP, errMsg: _.a[_.a.SDK_FUNCTIONS_EMPTY_POLL_RESULT_BASE_RESP] }, k));
                                if (0 !== t.status) { if (1 === t.status) { if (0 !== t.service_errcode) { var i = Object(u.g)({ errCode: _.a.SDK_FUNCTIONS_CLOUD_FUNCTION_EXECUTION_ERROR, errMsg: "requestID " + t.func_request_id + ", cloud function service error code " + (t.service_errcode || "unknown") + ", error message " + (t.service_errmsg || "unknown") + " (callid " + f + ")" }, k); return i.requestID = t.func_request_id, T(i) } var a = t.data; try { a = g(a) } catch (e) { try { a = JSON.parse(a) } catch (e) {} } return m({ result: a, requestID: t.func_request_id }) } return E.push(C("poll result expired")), T(Object(u.g)({ errCode: _.a.SDK_FUNCTIONS_POLL_RESULT_EXPIRED, errMsg: "timeout for result fetching, result cannot be fetched anymore (callId: " + f + ") (trace: " + D(E) + ")" }, k)) }
                                if (!(p >= 0)) return E.push(C("too many polls, abort")), T(Object(u.g)({ errCode: _.a.SDK_FUNCTIONS_EXCEED_MAX_POLL_RETRY, errMsg: _.a[_.a.SDK_FUNCTIONS_EXCEED_MAX_POLL_RETRY] + " (callId: " + f + ") (trace: " + D(E) + ")" }, k));
                                E.push(C("normal poll")), r(Object(o.a)(Object(o.a)({}, n), { action: j.POLL, scene: P.NORMAL_POLL_RETRY, tryCount: p - 1 }))
                            } catch (e) { T(Object(u.g)({ errCode: _.a.SDK_FUNCTIONS_POLL_ERROR, errMsg: "polling catch error: " + e + " (callId: " + f + ")" }, k)) }
                        }
                        var s, c, f, l, d, p, E, O, y, m, T, v, S, I, A, w, B, L, M, U = this;
                        return Object(o.d)(this, function(g) {
                            return s = n.functionName, c = n.data, f = n.callID, l = n.action, d = n.scene, p = n.tryCount, E = n.trace, O = n.systemErrorRetry, y = n.timeoutErrorRetry, m = n.resolve, T = n.reject, v = { function_name: s, data: l === j.CALL ? c : void 0, action: l, scene: d, call_id: f, cloudid_list: l === j.CALL ? a : [] }, S = b(v), I = !1, A = !1, w = function() { clearTimeout(L), A = !0 }, B = +new Date, L = setTimeout(function() {
                                return Object(o.b)(U, void 0, void 0, function() {
                                    var t;
                                    return Object(o.d)(this, function(i) {
                                        switch (i.label) {
                                            case 0:
                                                return t = e.appConfig.clientPollTimeout || R, +new Date - B > t ? [4, Object(N.f)()] : [3, 2];
                                            case 1:
                                                if (i.sent(), A) return [2];
                                                i.label = 2;
                                            case 2:
                                                return !Object(h.b)() && +new Date - B > e.appConfig.maxStartRetryGap ? (E.push(C("timeout, exceed max retry gap")), [2, T(Object(u.g)({ errCode: _.a.SDK_FUNCTIONS_POLL_RESULT_EXPIRED, errMsg: "timeout for retry, cannot retry fetching the result anymore (callId: " + f + ") (trace: " + D(E) + ")" }, k))]) : (I = !0, n.timeoutErrorRetry > 0 ? (E.push(C("timeout, retry")), r(Object(o.a)(Object(o.a)({}, n), { scene: P.TIMEOUT_RETRY, tryCount: p - 1, timeoutErrorRetry: y - 1 }))) : (E.push(C("timeout, abort")), T(Object(u.g)({ errCode: _.a.SDK_FUNCTIONS_EXCEED_MAX_TIMEOUT_POLL_RETRY, errMsg: _.a[_.a.SDK_FUNCTIONS_EXCEED_MAX_TIMEOUT_POLL_RETRY] + " (callId: " + f + ") (trace: " + D(E) + ")" }, k))), [2])
                                        }
                                    })
                                })
                            }, e.appConfig.clientPollTimeout || R), M = function(e) {
                                var n = e.data;
                                n && n.baseresponse && n.baseresponse.stat && (n.baseresponse.stat.qbase_cost_time && (t.context.tunnelTimeNoCSNetCost += n.baseresponse.stat.qbase_cost_time), n.baseresponse.stat.func_exec_cost_time && (t.context.funcExecTime = n.baseresponse.stat.func_exec_cost_time))
                            }, e.request({ apiName: "tcbapi_slowcallfunction_v2", serviceName: e.name, serializedReqData: S, env: t.config && t.config.env || e.env }).then(i).catch(function(e) { I || (w(), e && e.operateWXDataFail && O > 0 ? (E.push(C("system error (" + e + "), retry")), r(Object(o.a)(Object(o.a)({}, n), { scene: P.SYSTEM_ERROR_RETRY, tryCount: p - 1, systemErrorRetry: O - 1 }))) : (E.push(C("system error (" + e + "), abort")), T(Object(u.g)(e + " (callId: " + f + ") (trace: " + D(E) + ")", k)))) }), [2]
                        })
                    })
                }
                var i, a, c, f, l, d, E, O, y, m, T, S, B;
                return Object(o.d)(this, function(r) {
                    switch (r.label) {
                        case 0:
                            if (i = Object(o.a)({}, t.data), (a = v(i).map(function(e) { return { key_name: e.key, cloud_id: e.cloudID } })).length) try { for (c = Object(o.g)(a), f = c.next(); !f.done; f = c.next()) l = f.value, delete i[l.key_name] } catch (e) { S = { error: e } } finally { try { f && !f.done && (B = c.return) && B.call(c) } finally { if (S) throw S.error } }
                            return [4, t.cdnMapPromise];
                        case 1:
                            return d = r.sent(), E = b(i, d), Object(s.c)({ input: E, max: e.appConfig.maxReqDataSize, name: "callFunction data", maxWording: e.appConfig.maxReqDataSize / 1024 + " KB" }), O = +new Date + "-" + Math.random(), t.context.tunnelStartTime = +new Date, [4, n(t, E, a, O)];
                        case 2:
                            return y = r.sent(), m = y.result, T = y.requestID, t.context.tunnelEndTime = +new Date, [2, { errMsg: Object(p.b)(k), result: m, requestID: T }]
                    }
                })
            })
        }
    }

    function L(e) {
        return Object(o.b)(this, void 0, void 0, function() {
            var t, n;
            return Object(o.d)(this, function(r) {
                switch (r.label) {
                    case 0:
                        return t = new WeakMap, n = [], e ? (JSON.stringify(e, function(e, r) {
                            return r && r._internalType === T ? void n.push(new Promise(function(e, n) {
                                var i = { appType: 301, fileType: 20303, fileKey: "file_" + Math.random() },
                                    a = r;
                                switch (Object(f.a)(a.target)) {
                                    case "object":
                                        if (!a.target.filePath) throw new Error("filePath must be provided");
                                        i.filePath = a.target.filePath;
                                        break;
                                    default:
                                        i.fileData = a.target
                                }
                                e(function(e) { return new Promise(function(t, n) { Object(y.a)().uploadToCommonCDN(Object(o.a)(Object(o.a)({}, e), { success: t, fail: n })) }) }(i).then(function(e) { t.set(r, e.fileUrl) }))
                            })) : r
                        }), [4, Promise.all(n)]) : [3, 2];
                    case 1:
                        r.sent(), r.label = 2;
                    case 2:
                        return [2, t]
                }
            })
        })
    }
    var j, P, M, U = function(e) { return Object(o.a)(Object(o.a)({}, e), { errMsg: void 0 }) },
        x = function(e) { try { Object(h.b)() && "undefined" != typeof __global && __global.networkLog && __global.networkLog(Object(o.a)(Object(o.a)({}, e), { domain: "cloud", method: "POST", timestampMs: e.timestampMs || +new Date, callFramesIgnoreLength: e.hasOwnProperty("callFramesIgnoreLength") ? e.callFramesIgnoreLength : 1 })) } catch (e) {} },
        $ = function(e, t) {
            try {
                if (Object(h.b)() && "undefined" != typeof __global && __global.networkLog) {
                    var n = t(),
                        r = Math.random() + "-" + +new Date,
                        i = n.console || !1,
                        a = n.resultGetter || U;
                    x({ reqId: r, type: "requestWillBeSent", url: n.url, headers: n.headers || {}, body: n.reqBody, console: i, callFramesIgnoreLength: 2, timestampMs: n.timestampMs }), e.then(function(e) {
                        return Object(o.b)(void 0, void 0, void 0, function() {
                            return Object(o.d)(this, function(t) {
                                switch (t.label) {
                                    case 0:
                                        return t.trys.push([0, 2, , 3]), [4, function(e) { return void 0 === e && (e = 0), new Promise(function(t) { return setTimeout(t, e) }) }()];
                                    case 1:
                                        return t.sent(), x({ reqId: r, type: "loadingFinished", body: JSON.stringify(a(e), null, 2), console: i, callFramesIgnoreLength: 2 }), [3, 3];
                                    case 2:
                                        return t.sent(), [3, 3];
                                    case 3:
                                        return [2]
                                }
                            })
                        })
                    }).catch(function(e) { try { x({ reqId: r, type: "loadingFailed", errorCode: e && e.errCode || -1, errorMsg: Object(f.g)(e) ? e.errMsg || JSON.stringify(e) : e.toString(), console: i, callFramesIgnoreLength: 2 }) } catch (e) {} })
                }
            } catch (e) { 0 }
        };
    ! function(e) { e[e.CALL = 1] = "CALL", e[e.POLL = 2] = "POLL" }(j || (j = {})),
    function(e) { e[e.INITIATE_CALL = 1] = "INITIATE_CALL", e[e.NORMAL_POLL_RETRY = 2] = "NORMAL_POLL_RETRY", e[e.SYSTEM_ERROR_RETRY = 3] = "SYSTEM_ERROR_RETRY", e[e.TIMEOUT_RETRY = 4] = "TIMEOUT_RETRY" }(P || (P = {})),
    function(e) { e[e.PENDING = 0] = "PENDING", e[e.DONE = 1] = "DONE", e[e.TIMEOUT = 2] = "TIMEOUT" }(M || (M = {}));
    var k = "cloud.callFunction",
        F = "cloud.callFunction_real_v2";

    function W(e) {
        var t, n, r;

        function i() {
            return r || (r = function(e) {
                return function(t) {
                    return Object(o.b)(this, void 0, void 0, function() {
                        var n, r, i, a, s;
                        return Object(o.d)(this, function(o) {
                            switch (o.label) {
                                case 0:
                                    return n = { function_name: t.name, data: b(t.data), cloudid_list: [] }, r = b(n), [4, e.request({ apiName: "tcbapi_callfunction", serviceName: e.name, serializedReqData: r, env: t.config && t.config.env || e.env })];
                                case 1:
                                    if (i = o.sent(), a = i.data, s = a && a.data) try { s = JSON.parse(s) } catch (e) {}
                                    return [2, { errMsg: Object(p.b)(k), result: s }]
                            }
                        })
                    })
                }
            }(e)), r
        }
        return function(e) {
            var t = +new Date;
            Object(s.d)(e, "object");
            var n = l(e);
            return n.data || (n.data = {}), n.context = { tunnelTimeNoCSNetCost: 0 }, n.context.apiStartTime = t, Object(a.a)(n) ? function(e) { Object(c.b)({ apiName: k, param: e }), f(e).then(function(t) { Object(a.c)(k, e, t) }).catch(function(t) { Object(a.b)(k, e, t) }) }(n) : f(n)
        };

        function f(r) {
            return Object(o.b)(this, void 0, void 0, function() {
                function a() { return "devtools" === h.a.platform || Object(h.c)() || 1 === r.version }
                var c, f, l;
                return Object(o.d)(this, function(p) {
                    switch (p.label) {
                        case 0:
                            return p.trys.push([0, 8, 9, 10]),
                                function(e) { Object(s.d)(e, { name: "string" }), e.data && Object(s.d)(e.data, "object"), e.config && e.config.env && Object(s.d)(e.config.env, "string") }(r), r.cdnMapPromise = L(r.data), a() ? (c = (t || (t = S(e)), t)(r), Object(h.b)() && (f = Date.now(), r.cdnMapPromise.then(function(t) { $(c, function() { var n; return { url: "wx.cloud.callFunction." + r.name, headers: { Env: e.isInstance ? e.env : (null === (n = r.config) || void 0 === n ? void 0 : n.env) || e.env }, reqBody: b(r.data, t), timestampMs: f, console: e.debug } }) }).catch(function() { $(c, function() { var t; return { url: "wx.cloud.callFunction." + r.name, headers: { Env: e.isInstance ? e.env : (null === (t = r.config) || void 0 === t ? void 0 : t.env) || e.env }, reqBody: b(r.data), timestampMs: f, console: e.debug } }) })), [4, c]) : [3, 2];
                        case 1:
                            return [2, p.sent()];
                        case 2:
                            return [4, (n || (n = B(e)), n)(r)];
                        case 3:
                            return [2, p.sent()];
                        case 4:
                            return [3, 7];
                        case 5:
                            return [4, i()(r)];
                        case 6:
                            return [2, p.sent()];
                        case 7:
                            return [3, 10];
                        case 8:
                            throw l = p.sent(), Object(u.g)(l, k);
                        case 9:
                            return Object(d.b)(Object(o.a)(Object(o.a)({}, r.context), { apiEndTime: +new Date, apiName: a() ? k : F })), [7];
                        case 10:
                            return [2]
                    }
                })
            })
        }
    }
    var q = "functions";

    function z(e) { var t = { name: q, identifiers: e.identifiers, request: e.request, isInstance: e.isInstance, get debug() { return e.debug }, get env() { return e.getEnvForService(q) }, appConfig: {get maxReqDataSize() { return e.appConfig.call_function_max_req_data_size }, get maxPollRetry() { return e.appConfig.call_function_poll_max_retry }, get maxStartRetryGap() { return e.appConfig.call_function_valid_start_retry_gap }, get clientPollTimeout() { return e.appConfig.call_function_client_poll_timeout } } }; return { name: q, context: t, getAPIs: function(e) { return { callFunction: W(e) } }.bind(null, t) } }
    var Y = "cloud.callContainer";

    function G(e) {
        return function(e) {
            var n = +new Date;
            Object(s.d)(e, "object");
            var r = l(e);
            return r.data || (r.data = {}), r.context = { tunnelTimeNoCSNetCost: 0 }, r.context.apiStartTime = n, Object(a.a)(r) ? function(e) { Object(c.b)({ apiName: Y, param: e }), t(e).then(function(t) { Object(a.c)(Y, e, t) }).catch(function(t) { Object(a.b)(Y, e, t) }) }(r) : t(r)
        };

        function t(t) {
            return Object(o.b)(this, void 0, void 0, function() {
                var n, r, i, a;
                return Object(o.d)(this, function(c) {
                    switch (c.label) {
                        case 0:
                            return c.trys.push([0, 2, 3, 4]),
                                function(e) { Object(s.d)(e, { path: "string" }), e.config && e.config.env && Object(s.d)(e.config.env, "string") }(t), n = /post|put/i.test(t.method || "") && (!t.header || !t.header["content-type"] || "application/json" === t.header["content-type"]), t.cdnMapPromise = n ? L(t.data) : Promise.resolve(new Map), r = Date.now(), [4, i = Promise.all([t.cdnMapPromise, e.serviceEndpoint.getEndpoint("container")]).then(function(a) {
                                    var s = Object(o.e)(a, 2),
                                        u = s[0],
                                        c = s[1];
                                    try { $(i, function() { var n; return { url: "wx.cloud.callContainer" + t.path, headers: { Env: e.isInstance ? e.env : (null === (n = t.config) || void 0 === n ? void 0 : n.env) || e.env }, reqBody: b(t.data, u), timestampMs: r, console: e.debug } }) } catch (e) {}
                                    return n && (t.data = b(t.data, u)), t.header || (t.header = {}), t.header["content-type"] || (t.header["content-type"] = "application/json"),
                                        function(t, n) {
                                            return Object(o.b)(this, void 0, void 0, function() {
                                                return Object(o.d)(this, function(r) {
                                                    return [2, new Promise(function(r, i) {
                                                        var a = Object(y.a)(e.identifiers);
                                                        a._requestSkipCheckDomain({ url: t, method: n.method, header: Object(o.a)(Object(o.a)({}, n.header), { "X-WECHAT-ENV": e.env, "X-WECHAT-CONTAINER-PATH": n.path, "X-WECHAT-CALL-ID": Math.random() + "_" + Date.now() }), data: n.data, dataType: n.dataType, responseType: n.responseType, success: function(e) { r(e) }, fail: function(e) { i(e) } })
                                                    })]
                                                })
                                            })
                                        }(c.url, t)
                                })];
                        case 1:
                            return [2, c.sent()];
                        case 2:
                            throw a = c.sent(), Object(u.g)(a, Y);
                        case 3:
                            return Object(d.b)(Object(o.a)(Object(o.a)({}, t.context), { apiEndTime: +new Date, apiName: Y })), [7];
                        case 4:
                            return [2]
                    }
                })
            })
        }
    }
    var H = "container";

    function K(e) { var t = { name: H, identifiers: e.identifiers, request: e.request, isInstance: e.isInstance, serviceEndpoint: e.serviceEndpoint, get debug() { return e.debug }, get env() { return e.getEnvForService(H) }, appConfig: {} }; return { name: H, context: t, getAPIs: function(e) { return { callContainer: G(e) } }.bind(null, t) } }
    var V = n(45),
        X = "cloud.uploadFile",
        J = "cloud.uploadFile_v2";

    function Q(e) {
        return function(e) {
            if (e = l(e), Object(a.a)(e)) return function(e) {
                var n = { aborted: !1 },
                    r = function(e) { return { onProgressUpdate: function(t) { e.onProgressUpdateUserHandler = t }, abort: function() { e.abort && e.abort(), e.aborted = !0 } } }(n),
                    i = { apiStartTime: +new Date };
                return t(Object(o.a)(Object(o.a)({}, e), { context: n, timing: i, uploadTaskAgent: r })).then(function(t) { Object(a.c)(X, e, t) }).catch(function(t) { Object(a.b)(X, e, t) }), r
            }(e);
            var n = { apiStartTime: +new Date };
            return t(Object(o.a)(Object(o.a)({}, e), { timing: n }))
        };

        function t(t) {
            var n = this;
            return new Promise(function(r, i) {
                return Object(o.b)(n, void 0, void 0, function() {
                    var n, a;
                    return Object(o.d)(this, function(c) {
                        switch (c.label) {
                            case 0:
                                return c.trys.push([0, 2, 3, 4]),
                                    function(e) { Object(s.d)(e, { cloudPath: "string" }), "miniprogram" === Object(V.a)().env ? Object(s.d)(e, { filePath: "string" }) : Object(s.b)(e, "file", "uploadFile") }(t), t.filePath && function(t) { Object(o.b)(this, void 0, void 0, function() { return Object(o.d)(this, function(n) { return [2, new Promise(function(n, r) { wx.getFileInfo ? wx.getFileInfo({ filePath: t, success: function(t) { t.size > e.appConfig.uploadMaxFileSize ? r(new u.b({ errCode: _.a.SDK_STORAGE_EXCEED_MAX_UPLOAD_SIZE, errMsg: "exceed max upload file size: " + e.appConfig.uploadMaxFileSize / 1024 / 1024 + " MB" })) : n() }, fail: function() { n() } }) : n() })] }) }) }(t.filePath), t.context && (t.context.abort = function() { i(Object(u.g)({ errMsg: "abort" }, X)) }, t.context.aborted) ? [2, i(Object(u.g)({ errMsg: "abort" }, X))] : [4, function(t) {
                                        return Object(o.b)(this, void 0, void 0, function() {
                                            var n, r;
                                            return Object(o.d)(this, function(i) {
                                                switch (i.label) {
                                                    case 0:
                                                        return n = Object(y.a)(e.identifiers), [4, function(t) {
                                                            return Object(o.b)(this, void 0, void 0, function() {
                                                                var n, r, i, a;
                                                                return Object(o.d)(this, function(o) {
                                                                    switch (o.label) {
                                                                        case 0:
                                                                            return n = JSON.stringify({ path: t.cloudPath }), r = +new Date, [4, e.request({ apiName: "tcbapi_cos_uploadfile", serviceName: e.name, serializedReqData: n, env: t.config && t.config.env || e.env })];
                                                                        case 1:
                                                                            if (i = o.sent(), a = i.data, t.timing && (t.timing.tunnelStartTime = r, t.timing.tunnelEndTime = +new Date, t.timing.tunnelTimeNoCSNetCost = a.baseresponse.stat.qbase_cost_time), !a.url) throw new u.b({ errCode: _.a.SDK_STORAGE_INTERNAL_SERVER_ERROR_EMPTY_UPLOAD_URL, errMsg: _.a[_.a.SDK_STORAGE_INTERNAL_SERVER_ERROR_EMPTY_UPLOAD_URL] });
                                                                            return [2, a]
                                                                    }
                                                                })
                                                            })
                                                        }(t)];
                                                    case 1:
                                                        return r = i.sent(), [2, new Promise(function(e, i) {
                                                            if (t.context && t.context.aborted) return i(Object(u.g)({ errMsg: "abort" }, X));
                                                            var a, s, c = Object(V.a)();
                                                            if ("web" === c.env) {
                                                                var l = new FormData;
                                                                l.append("key", t.cloudPath), l.append("signature", r.authorization), l.append("x-cos-security-token", r.token), l.append("x-cos-meta-fileid", r.cos_file_id), l.append("file", t.file), a = { url: r.url, timeout: t.timeout, filePath: "", header: t.header, name: "", formData: l }
                                                            } else a = { url: r.url, timeout: t.timeout, filePath: t.filePath, header: t.header, name: "file", formData: { key: t.cloudPath, signature: r.authorization, "x-cos-security-token": r.token, "x-cos-meta-fileid": r.cos_file_id } };
                                                            (s = n._uploadFileSkipCheckDomain(Object(o.a)(Object(o.a)({}, a), {
                                                                success: function(t) {
                                                                    try {
                                                                        if (t.statusCode >= 200 && t.statusCode < 300) e({ errMsg: Object(p.b)(X), fileID: r.file_id, statusCode: t.statusCode });
                                                                        else {
                                                                            var n = new u.b({ errMsg: "status " + t.statusCode + ", error: " + t.data + ";" });
                                                                            i(n)
                                                                        }
                                                                    } catch (n) {
                                                                        var o = new u.b({ errMsg: "Error : " + t.data + ";" });
                                                                        i(o)
                                                                    }
                                                                },
                                                                fail: function(e) { i(e) }
                                                            }))) && (s.onProgressUpdate(function() { t.uploadTaskAgent && t.context && t.context.onProgressUpdateUserHandler && Object(f.d)(t.context.onProgressUpdateUserHandler) && t.context.onProgressUpdateUserHandler.apply(n._uploadFileSkipCheckDomain, arguments) }), t.context && (t.context.abort = s.abort.bind(s)))
                                                        })]
                                                }
                                            })
                                        })
                                    }(t)];
                            case 1:
                                return n = c.sent(), r(n), [3, 4];
                            case 2:
                                return a = c.sent(), i(Object(u.g)(a, X)), [3, 4];
                            case 3:
                                return Object(d.b)(Object(o.a)(Object(o.a)({}, t.timing), { apiEndTime: +new Date, apiName: J })), [7];
                            case 4:
                                return [2]
                        }
                    })
                })
            })
        }
    }
    var Z = "cloud.downloadFile";

    function ee(e) {
        return function(e) {
            if (e = l(e), Object(a.a)(e)) return function(e) {
                var n = { aborted: !1 },
                    r = function(e) { return { onProgressUpdate: function(t) { e.onProgressUpdateUserHandler = t }, abort: function() { e.abort && e.abort(), e.aborted = !0 } } }(n),
                    i = { apiStartTime: +new Date };
                return t(Object(o.a)(Object(o.a)({}, e), { context: n, timing: i, downloadTaskAgent: r })).then(function(t) { Object(a.c)(Z, e, t) }).catch(function(t) { Object(a.b)(Z, e, t) }), r
            }(e);
            var n = { apiStartTime: +new Date };
            return t(Object(o.a)(Object(o.a)({}, e), { timing: n }))
        };

        function t(t) {
            return Object(o.b)(this, void 0, void 0, function() {
                var n = this;
                return Object(o.d)(this, function(r) {
                    return [2, new Promise(function(r, i) {
                        return Object(o.b)(n, void 0, void 0, function() {
                            var n, a;
                            return Object(o.d)(this, function(c) {
                                switch (c.label) {
                                    case 0:
                                        return c.trys.push([0, 2, 3, 4]),
                                            function(e) { Object(s.d)(e, { fileID: "string" }), e.config && e.config.env && Object(s.d)(e.config.env, "string") }(t), t.context && (t.context.abort = function() { i(Object(u.g)({ errMsg: "abort" }, Z)) }, t.context.aborted) ? [2, i(Object(u.g)({ errMsg: "abort" }, Z))] : [4, function(t) {
                                                return Object(o.b)(this, void 0, void 0, function() {
                                                    var n, r;
                                                    return Object(o.d)(this, function(i) {
                                                        switch (i.label) {
                                                            case 0:
                                                                return n = Object(y.a)(e.identifiers), [4, function(t) {
                                                                    return Object(o.b)(this, void 0, void 0, function() {
                                                                        var n, r, i, a;
                                                                        return Object(o.d)(this, function(o) {
                                                                            switch (o.label) {
                                                                                case 0:
                                                                                    return n = JSON.stringify({ fileid: t.fileID }), r = +new Date, [4, e.request({ apiName: "tcbapi_downloadfile", serviceName: e.name, serializedReqData: n, env: t.config && t.config.env || e.env })];
                                                                                case 1:
                                                                                    if (i = o.sent(), a = i.data, t.timing && (t.timing.tunnelStartTime = r, t.timing.tunnelEndTime = +new Date, t.timing.tunnelTimeNoCSNetCost = a.baseresponse.stat.qbase_cost_time), !a.download_url) throw new u.b({ errCode: _.a.SDK_STORAGE_INTERNAL_SERVER_ERROR_EMPTY_DOWNLOAD_URL, errMsg: _.a[_.a.SDK_STORAGE_INTERNAL_SERVER_ERROR_EMPTY_DOWNLOAD_URL] });
                                                                                    return a.download_url.indexOf("?") > -1 ? a.download_url += "&skip_domain_check=true" : a.download_url += "?skip_domain_check=true", [2, a.download_url]
                                                                            }
                                                                        })
                                                                    })
                                                                }(t)];
                                                            case 1:
                                                                return r = i.sent(), [2, new Promise(function(e, i) {
                                                                    if (t.context && t.context.aborted) return i(Object(u.g)({ errMsg: "abort" }, Z));
                                                                    var o = n._downloadFileSkipCheckDomain({ url: r, success: function(t) { e(t) }, fail: function(e) { i(e) } });
                                                                    o && (o.onProgressUpdate(function() { t.downloadTaskAgent && t.context && t.context.onProgressUpdateUserHandler && Object(f.d)(t.context.onProgressUpdateUserHandler) && t.context.onProgressUpdateUserHandler.apply(n._downloadFileSkipCheckDomain, arguments) }), t.context && (t.context.abort = o.abort.bind(o)))
                                                                })]
                                                        }
                                                    })
                                                })
                                            }(t)];
                                    case 1:
                                        return n = c.sent(), r(n), [3, 4];
                                    case 2:
                                        return a = c.sent(), i(Object(u.g)(a, Z)), [3, 4];
                                    case 3:
                                        return Object(d.b)(Object(o.a)(Object(o.a)({}, t.timing), { apiEndTime: +new Date, apiName: Z })), [7];
                                    case 4:
                                        return [2]
                                }
                            })
                        })
                    })]
                })
            })
        }
    }
    var te = "cloud.getTempFileURL";

    function ne(e) {
        return function(e) { var n = l(e); return n.timing = { apiStartTime: +new Date }, Object(a.a)(n) ? function(e) { t(e).then(function(t) { Object(a.c)(te, e, t) }).catch(function(t) { Object(a.b)(te, e, t) }) }(n) : t(n) };

        function t(t) {
            return Object(o.b)(this, void 0, void 0, function() {
                var n;
                return Object(o.d)(this, function(r) {
                    switch (r.label) {
                        case 0:
                            return r.trys.push([0, 2, 3, 4]),
                                function(t) { if (Object(s.d)(t, { fileList: "array" }), t.config && t.config.env && Object(s.d)(t.config.env, "string"), e.appConfig.getTempFileURLMaxReq && t.fileList.length > e.appConfig.getTempFileURLMaxReq) throw new u.b({ errCode: _.a.SDK_API_PARAMETER_ERROR, errMsg: "parameter.fileList exceed max length " + e.appConfig.getTempFileURLMaxReq }) }(t), t.fileList.length ? [4, function(t) {
                                    return Object(o.b)(this, void 0, void 0, function() {
                                        var n, r, i, a;
                                        return Object(o.d)(this, function(o) {
                                            switch (o.label) {
                                                case 0:
                                                    return n = { file_list: t.fileList.map(function(e) { return Object(f.k)(e) ? { fileid: e } : { fileid: e.fileID, max_age: e.maxAge } }) }, r = JSON.stringify(n), t.timing.tunnelStartTime = +new Date, [4, e.request({ apiName: "tcbapi_gettempfileurl", serviceName: e.name, serializedReqData: r, env: t.config && t.config.env || e.env })];
                                                case 1:
                                                    return i = o.sent(), t.timing.tunnelEndTime = +new Date, a = i.data, t.timing.tunnelTimeNoCSNetCost = a.baseresponse.stat.qbase_cost_time, [2, { errMsg: Object(p.b)(te), fileList: a.download_list.map(function(e) { return { fileID: e.fileid, tempFileURL: e.download_url, maxAge: e.max_age, status: e.status, errMsg: e.errmsg } }) }]
                                            }
                                        })
                                    })
                                }(t)] : [2, { errMsg: Object(p.b)(te), fileList: [] }];
                        case 1:
                            return [2, r.sent()];
                        case 2:
                            throw n = r.sent(), Object(u.g)(n, te);
                        case 3:
                            return Object(d.b)(Object(o.a)(Object(o.a)({}, t.timing), { apiEndTime: +new Date, apiName: te })), [7];
                        case 4:
                            return [2]
                    }
                })
            })
        }
    }
    var re = "cloud.deleteFile";

    function ie(e) {
        return function(e) { var n = l(e); return n.timing = { apiStartTime: +new Date }, Object(a.a)(n) ? function(e) { t(e).then(function(t) { Object(a.c)(re, e, t) }).catch(function(t) { Object(a.b)(re, e, t) }) }(n) : t(n) };

        function t(t) {
            return Object(o.b)(this, void 0, void 0, function() {
                var n;
                return Object(o.d)(this, function(r) {
                    switch (r.label) {
                        case 0:
                            return r.trys.push([0, 2, 3, 4]),
                                function(t) { Object(s.d)(t, { fileList: "array" }), t.config && t.config.env && Object(s.d)(t.config.env, "string"); for (var n = 0, r = t.fileList.length; n < r; n++) Object(s.d)(t.fileList[n], "string", "parameter.fileList[" + n + "]"); if (e.appConfig.getTempFileURLMaxReq && t.fileList.length > e.appConfig.getTempFileURLMaxReq) throw new u.b({ errCode: _.a.SDK_API_PARAMETER_ERROR, errMsg: "parameter.fileList exceed max length " + e.appConfig.getTempFileURLMaxReq }) }(t), t.fileList.length ? [4, function(t) {
                                    return Object(o.b)(this, void 0, void 0, function() {
                                        var n, r, i, a;
                                        return Object(o.d)(this, function(o) {
                                            switch (o.label) {
                                                case 0:
                                                    return n = { fileid_list: t.fileList }, r = JSON.stringify(n), t.timing.tunnelStartTime = +new Date, [4, e.request({ apiName: "tcbapi_deletefile", serviceName: e.name, serializedReqData: r, env: t.config && t.config.env || e.env })];
                                                case 1:
                                                    return i = o.sent(), t.timing.tunnelEndTime = +new Date, a = i.data, t.timing.tunnelTimeNoCSNetCost = a.baseresponse.stat.qbase_cost_time, [2, { errMsg: Object(p.b)(re), fileList: a.delete_list.map(function(e) { return { fileID: e.fileid, status: e.status, errMsg: e.errmsg } }) }]
                                            }
                                        })
                                    })
                                }(t)] : [2, { errMsg: Object(p.b)(re), fileList: [] }];
                        case 1:
                            return [2, r.sent()];
                        case 2:
                            throw n = r.sent(), Object(u.g)(n, re);
                        case 3:
                            return Object(d.b)(Object(o.a)(Object(o.a)({}, t.timing), { apiEndTime: +new Date, apiName: re })), [7];
                        case 4:
                            return [2]
                    }
                })
            })
        }
    }
    var oe = "storage";

    function ae(e) { var t = { name: oe, identifiers: e.identifiers, request: e.request, isInstance: e.isInstance, get env() { return e.getEnvForService(oe) }, get debug() { return e.debug }, appConfig: {get uploadMaxFileSize() { return e.appConfig.upload_max_file_size }, get getTempFileURLMaxReq() { return e.appConfig.get_temp_file_url_max_requests } } }; return { name: oe, context: t, getAPIs: function(e) { return { uploadFile: Q(e), downloadFile: ee(e), getTempFileURL: ne(e), deleteFile: ie(e) } }.bind(null, t) } }
    var se, ue = Symbol.for("UNSET_FIELD_NAME"),
        ce = Symbol.for("AGGREGATE"),
        fe = Symbol.for("AGGREGATE_PIPELINE"),
        le = Symbol.for("AGGREGATE_PIPELINE_STAGE"),
        de = Symbol.for("UPDATE_COMMAND"),
        he = Symbol.for("QUERY_COMMAND"),
        pe = Symbol.for("LOGIC_COMMAND"),
        _e = Symbol.for("AGGREGATE_COMMAND"),
        be = Symbol.for("PROJECT_COMMAND"),
        ge = Symbol.for("GEO_POINT"),
        Ee = Symbol.for("GEO_LINESTRING"),
        Oe = Symbol.for("GEO_POLYGON"),
        ye = Symbol.for("GEO_MULTIPOINT"),
        me = Symbol.for("GEO_MULTILINESTRING"),
        Te = Symbol.for("GEO_MULTIPOLYGON"),
        ve = Symbol.for("SERVER_DATE"),
        Se = Symbol.for("REGEXP");
    ! function(e) { e.AND = "and", e.OR = "or", e.NOT = "not", e.NOR = "nor" }(se || (se = {}));
    var Ne = [se.AND, se.OR, se.NOT, se.NOR],
        Ie = new Set(Ne),
        Ae = function() {
            function e(e, t, n) { this._internalType = pe, Object.defineProperties(this, { _internalType: { enumerable: !1, configurable: !1 } }), this.operator = e, this.operands = t, this.fieldName = n || ue }
            return e.prototype._setFieldName = function(t) { var n = this.operands.map(function(e) { return e === se.AND || e === se.OR ? e._setFieldName(t) : e }); return new e(this.operator, n, t) }, e.prototype.and = function() {
                for (var t = [], n = 0; n < arguments.length; n++) t[n] = arguments[n];
                Object(s.b)(arguments[0], "expressions", "and");
                var r = Object(f.b)(arguments[0]) ? arguments[0] : Array.from(arguments);
                return r.unshift(this), new e(se.AND, r, this.fieldName)
            }, e.prototype.or = function() {
                for (var t = [], n = 0; n < arguments.length; n++) t[n] = arguments[n];
                Object(s.b)(arguments[0], "expressions", "or");
                var r = Object(f.b)(arguments[0]) ? arguments[0] : Array.from(arguments);
                return r.unshift(this), new e(se.OR, r, this.fieldName)
            }, e.prototype.nor = function() {
                for (var t = [], n = 0; n < arguments.length; n++) t[n] = arguments[n];
                Object(s.b)(arguments[0], "expressions", "nor");
                var r = Object(f.b)(arguments[0]) ? arguments[0] : Array.from(arguments);
                return r.unshift(this), new e(se.NOR, r, this.fieldName)
            }, e.prototype.not = function(t) { return Object(s.b)(t, "expression", "not"), new e(se.NOT, [t], this.fieldName) }, e.prototype.toJSON = function() {}, e
        }();

    function we(e) { return e && e instanceof Ae && e._internalType === pe }
    var Re;
    ! function(e) { e.EQ = "eq", e.NEQ = "neq", e.GT = "gt", e.GTE = "gte", e.LT = "lt", e.LTE = "lte", e.IN = "in", e.NIN = "nin", e.GEO_NEAR = "geoNear", e.GEO_WITHIN = "geoWithin", e.GEO_INTERSECTS = "geoIntersects", e.EXISTS = "exists", e.MOD = "mod", e.ALL = "all", e.ELEM_MATCH = "elemMatch", e.SIZE = "size", e.EXPR = "expr" }(Re || (Re = {}));
    var Ce = [Re.EQ, Re.NEQ, Re.GT, Re.GTE, Re.LT, Re.LTE, Re.IN, Re.NIN, Re.GEO_NEAR, Re.GEO_WITHIN, Re.GEO_INTERSECTS, Re.EXISTS, Re.MOD, Re.ALL, Re.ELEM_MATCH, Re.SIZE],
        De = new Set(Ce),
        Be = (new Set(Object(o.f)(De, Ie)), function(e) {
            function t(t, n, r) { var i = e.call(this, t, n, r) || this; return i.operator = t, i._internalType = he, i }
            return Object(o.c)(t, e), t.prototype._setFieldName = function(e) { return new t(this.operator, this.operands, e) }, t.prototype.eq = function(e) { var n = new t(Re.EQ, [e], this.fieldName); return this.and(n) }, t.prototype.neq = function(e) { var n = new t(Re.NEQ, [e], this.fieldName); return this.and(n) }, t.prototype.gt = function(e) { var n = new t(Re.GT, [e], this.fieldName); return this.and(n) }, t.prototype.gte = function(e) { var n = new t(Re.GTE, [e], this.fieldName); return this.and(n) }, t.prototype.lt = function(e) { var n = new t(Re.LT, [e], this.fieldName); return this.and(n) }, t.prototype.lte = function(e) { var n = new t(Re.LTE, [e], this.fieldName); return this.and(n) }, t.prototype.in = function(e) { Object(s.d)(e, "array"); var n = new t(Re.IN, e, this.fieldName); return this.and(n) }, t.prototype.nin = function(e) { Object(s.d)(e, "array"); var n = new t(Re.NIN, e, this.fieldName); return this.and(n) }, t.prototype.geoNear = function(e) { var n = new t(Re.GEO_NEAR, [e], this.fieldName); return this.and(n) }, t.prototype.geoWithin = function(e) { var n = new t(Re.GEO_WITHIN, [e], this.fieldName); return this.and(n) }, t.prototype.geoIntersects = function(e) { var n = new t(Re.GEO_INTERSECTS, [e], this.fieldName); return this.and(n) }, t.prototype.exists = function(e) { var n = new t(Re.EXISTS, [e], this.fieldName); return this.and(n) }, t.prototype.mod = function(e, n) { var r = new t(Re.MOD, [e, n], this.fieldName); return this.and(r) }, t.prototype.all = function(e) { var n = new t(Re.ALL, e, this.fieldName); return this.and(n) }, t.prototype.elemMatch = function(e) { var n = new t(Re.ELEM_MATCH, [e], this.fieldName); return this.and(n) }, t.prototype.size = function(e) { var n = new t(Re.SIZE, [e], this.fieldName); return this.and(n) }, t
        }(Ae));

    function Le(e) { return e && e instanceof Be && e._internalType === he }
    var je;
    ! function(e) { e.SET = "set", e.REMOVE = "remove", e.INC = "inc", e.MUL = "mul", e.MIN = "min", e.MAX = "max", e.RENAME = "rename", e.BIT = "bit", e.PUSH = "push", e.POP = "pop", e.SHIFT = "shift", e.UNSHIFT = "unshift", e.ADD_TO_SET = "addToSet", e.PULL = "pull", e.PULL_ALL = "pullAll" }(je || (je = {}));
    new Set([je.SET, je.REMOVE, je.INC, je.MUL, je.MIN, je.MAX, je.RENAME, je.BIT, je.PUSH, je.POP, je.SHIFT, je.UNSHIFT, je.ADD_TO_SET, je.PULL, je.PULL_ALL]);
    var Pe = function() {
        function e(e, t, n) { this._internalType = de, Object.defineProperties(this, { _internalType: { enumerable: !1, configurable: !1 } }), this.operator = e, this.operands = t, this.fieldName = n || ue }
        return e.prototype._setFieldName = function(t) { return new e(this.operator, this.operands, t) }, e.prototype.toJSON = function() {}, e
    }();

    function Me(e) { return e && e instanceof Pe && e._internalType === de }
    var Ue;
    ! function(e) { e.ABS = "abs", e.ADD = "add", e.ADDTOSET = "addToSet", e.ALLELEMENTSTRUE = "allElementsTrue", e.AND = "and", e.ANYELEMENTTRUE = "anyElementTrue", e.ARRAYELEMAT = "arrayElemAt", e.ARRAYTOOBJECT = "arrayToObject", e.AVG = "avg", e.CEIL = "ceil", e.CMP = "cmp", e.CONCAT = "concat", e.CONCATARRAYS = "concatArrays", e.COND = "cond", e.CONVERT = "convert", e.DATEFROMPARTS = "dateFromParts", e.DATETOPARTS = "dateToParts", e.DATEFROMSTRING = "dateFromString", e.DATETOSTRING = "dateToString", e.DAYOFMONTH = "dayOfMonth", e.DAYOFWEEK = "dayOfWeek", e.DAYOFYEAR = "dayOfYear", e.DIVIDE = "divide", e.EQ = "eq", e.EXP = "exp", e.FILTER = "filter", e.FIRST = "first", e.FLOOR = "floor", e.GT = "gt", e.GTE = "gte", e.HOUR = "hour", e.IFNULL = "ifNull", e.IN = "in", e.INDEXOFARRAY = "indexOfArray", e.INDEXOFBYTES = "indexOfBytes", e.INDEXOFCP = "indexOfCP", e.ISARRAY = "isArray", e.ISODAYOFWEEK = "isoDayOfWeek", e.ISOWEEK = "isoWeek", e.ISOWEEKYEAR = "isoWeekYear", e.LAST = "last", e.LET = "let", e.LITERAL = "literal", e.LN = "ln", e.LOG = "log", e.LOG10 = "log10", e.LT = "lt", e.LTE = "lte", e.LTRIM = "ltrim", e.MAP = "map", e.MAX = "max", e.MERGEOBJECTS = "mergeObjects", e.META = "meta", e.MIN = "min", e.MILLISECOND = "millisecond", e.MINUTE = "minute", e.MOD = "mod", e.MONTH = "month", e.MULTIPLY = "multiply", e.NEQ = "ne", e.NOT = "not", e.OBJECTTOARRAY = "objectToArray", e.OR = "or", e.POW = "pow", e.PUSH = "push", e.RANGE = "range", e.REDUCE = "reduce", e.REVERSEARRAY = "reverseArray", e.RTRIM = "rtrim", e.SECOND = "second", e.SETDIFFERENCE = "setDifference", e.SETEQUALS = "setEquals", e.SETINTERSECTION = "setIntersection", e.SETISSUBSET = "setIsSubset", e.SETUNION = "setUnion", e.SIZE = "size", e.SLICE = "slice", e.SPLIT = "split", e.SQRT = "sqrt", e.STDDEVPOP = "stdDevPop", e.STDDEVSAMP = "stdDevSamp", e.STRCASECMP = "strcasecmp", e.STRLENBYTES = "strLenBytes", e.STRLENCP = "strLenCP", e.SUBSTR = "substr", e.SUBSTRBYTES = "substrBytes", e.SUBSTRCP = "substrCP", e.SUBTRACT = "subtract", e.SUM = "sum", e.SWITCH = "switch", e.TOBOOL = "toBool", e.TODATE = "toDate", e.TODECIMAL = "toDecimal", e.TODOUBLE = "toDouble", e.TOINT = "toInt", e.TOLONG = "toLong", e.TOOBJECTID = "toObjectId", e.TOSTRING = "toString", e.TOLOWER = "toLower", e.TOUPPER = "toUpper", e.TRIM = "trim", e.TRUNC = "trunc", e.TYPE = "type", e.WEEK = "week", e.YEAR = "year", e.ZIP = "zip" }(Ue || (Ue = {}));
    Ue.ABS, Ue.ADD, Ue.ADDTOSET, Ue.ALLELEMENTSTRUE, Ue.AND, Ue.ANYELEMENTTRUE, Ue.ARRAYELEMAT, Ue.ARRAYTOOBJECT, Ue.AVG, Ue.CEIL, Ue.CMP, Ue.CONCAT, Ue.CONCATARRAYS, Ue.COND, Ue.CONVERT, Ue.DATEFROMPARTS, Ue.DATETOPARTS, Ue.DATEFROMSTRING, Ue.DATETOSTRING, Ue.DAYOFMONTH, Ue.DAYOFWEEK, Ue.DAYOFYEAR, Ue.DIVIDE, Ue.EQ, Ue.EXP, Ue.FILTER, Ue.FIRST, Ue.FLOOR, Ue.GT, Ue.GTE, Ue.HOUR, Ue.IFNULL, Ue.IN, Ue.INDEXOFARRAY, Ue.INDEXOFBYTES, Ue.INDEXOFCP, Ue.ISARRAY, Ue.ISODAYOFWEEK, Ue.ISOWEEK, Ue.ISOWEEKYEAR, Ue.LAST, Ue.LET, Ue.LITERAL, Ue.LN, Ue.LOG, Ue.LOG10, Ue.LT, Ue.LTE, Ue.LTRIM, Ue.MAP, Ue.MAX, Ue.MERGEOBJECTS, Ue.META, Ue.MIN, Ue.MILLISECOND, Ue.MINUTE, Ue.MOD, Ue.MONTH, Ue.MULTIPLY, Ue.NEQ, Ue.NOT, Ue.OBJECTTOARRAY, Ue.OR, Ue.POW, Ue.PUSH, Ue.RANGE, Ue.REDUCE, Ue.REVERSEARRAY, Ue.RTRIM, Ue.SECOND, Ue.SETDIFFERENCE, Ue.SETEQUALS, Ue.SETINTERSECTION, Ue.SETISSUBSET, Ue.SETUNION, Ue.SIZE, Ue.SLICE, Ue.SPLIT, Ue.SQRT, Ue.STDDEVPOP, Ue.STDDEVSAMP, Ue.STRCASECMP, Ue.STRLENBYTES, Ue.STRLENCP, Ue.SUBSTR, Ue.SUBSTRBYTES, Ue.SUBSTRCP, Ue.SUBTRACT, Ue.SUM, Ue.SWITCH, Ue.TOBOOL, Ue.TODATE, Ue.TODECIMAL, Ue.TODOUBLE, Ue.TOINT, Ue.TOLONG, Ue.TOOBJECTID, Ue.TOSTRING, Ue.TOLOWER, Ue.TOUPPER, Ue.TRIM, Ue.TRUNC, Ue.TYPE, Ue.WEEK, Ue.YEAR, Ue.ZIP;
    var xe = function() {
        function e(e, t, n) { this._internalType = _e, Object.defineProperties(this, { _internalType: { enumerable: !1, configurable: !1 } }), this.operator = e, this.operands = t, this.fieldName = n || ue }
        return e.prototype._setFieldName = function(t) { return new e(this.operator, this.operands, t) }, e
    }();

    function $e(e) { return e && e instanceof xe && e._internalType === _e }
    var ke;
    ! function(e) { e.SLICE = "slice" }(ke || (ke = {}));
    new Set([ke.SLICE]);
    var Fe = function() {
        function e(e, t, n) { this._internalType = be, this.operator = e, this.operands = t, this.fieldName = n || ue }
        return e.prototype._setFieldName = function(t) { return new e(this.operator, this.operands, t) }, e
    }();

    function We(e) { return e && e instanceof Fe && e._internalType === be }
    var qe, ze, Ye;

    function Ge(e) {
        return Object(o.b)(this, void 0, void 0, function() {
            var t, r, i, a, s, u, c, f, l, d, p;
            return Object(o.d)(this, function(o) {
                switch (o.label) {
                    case 0:
                        return t = e.collectionName, r = e.query, i = e.options, a = e.instanceContext, s = e.timing, u = e.env, c = Object(h.b)() ? e.explain : void 0, f = i && i.multi, l = JSON.stringify({ collection_name: t, query: JSON.stringify(r), multi: f, query_type: f ? qe.WHERE : qe.DOC, explain: c }), s.tunnelStartTime = +new Date, [4, a.serviceContext.request({ apiName: "tcbapi_db_deletedocument", serviceName: a.serviceContext.name, serializedReqData: l, requireDataNotEmpty: !0, env: u || a.serviceContext.env })];
                    case 1:
                        return d = o.sent(), s.tunnelEndTime = +new Date, c ? [2, n(30).EJSON.deserialize(d.data)] : (p = d.data, s.tunnelTimeNoCSNetCost = p.baseresponse.stat.qbase_cost_time, [2, { removed: p.deleted }])
                }
            })
        })
    }

    function He(e) {
        return Object(o.b)(this, void 0, void 0, function() {
            var t, r, i, a, s, u, c, f, l, d, p, _, b, g;
            return Object(o.d)(this, function(o) {
                switch (o.label) {
                    case 0:
                        return t = e.env, r = e.collectionName, i = e.query, a = e.options, s = void 0 === a ? {} : a, u = e.instanceContext, c = e.timing, f = e.queryType, l = Object(h.b)() ? e.explain : void 0, d = { collection_name: r, query: JSON.stringify(i), query_type: f, explain: l }, s.offset && (d.offset = s.offset), s.limit && (d.limit = s.limit), s.order && (d.order = s.order), s.projection && (d.projection = JSON.stringify(s.projection)), p = JSON.stringify(d), c.tunnelStartTime = +new Date, [4, u.serviceContext.request({ apiName: "tcbapi_db_querydocument", serviceName: u.serviceContext.name, serializedReqData: p, requireDataNotEmpty: !0, env: t || u.serviceContext.env })];
                    case 1:
                        return _ = o.sent(), c.tunnelEndTime = +new Date, l ? [2, n(30).EJSON.deserialize(_.data)] : (b = _.data, c.tunnelTimeNoCSNetCost = b.baseresponse.stat.qbase_cost_time, g = b.data_list ? JSON.parse(b.data_list) : [], [2, { list: g = u.engine.Decoder.decode(g), offset: b.offset, limit: b.limit, total: b.total }])
                }
            })
        })
    }

    function Ke(e) {
        return Object(o.b)(this, void 0, void 0, function() {
            var t, r, i, a, u, c, f, l, d, p, _, b, g, E, O;
            return Object(o.d)(this, function(o) {
                switch (o.label) {
                    case 0:
                        return t = e.env, r = e.collectionName, i = e.query, a = e.data, u = e.options, c = void 0 === u ? {} : u, f = e.instanceContext, l = e.timing, d = e.queryType, p = Object(h.b)() ? e.explain : void 0, _ = JSON.stringify(a), Object(s.c)({ input: _, max: f.serviceContext.appConfig.docSizeLimit, name: "update expression", maxWording: (f.serviceContext.appConfig.docSizeLimit / 1024).toFixed(0) + " KB" }), (b = { collection_name: r, query: JSON.stringify(i), data: _, query_type: d, explain: p }).multi = !1 !== c.multi, b.merge = !1 !== c.merge, c.upsert && (b.upsert = c.upsert), g = JSON.stringify(b), l.tunnelStartTime = +new Date, [4, f.serviceContext.request({ apiName: "tcbapi_db_updatedocument", serviceName: f.serviceContext.name, serializedReqData: g, requireDataNotEmpty: !0, env: t || f.serviceContext.env })];
                    case 1:
                        return E = o.sent(), l.tunnelEndTime = +new Date, p ? [2, n(30).EJSON.deserialize(E.data)] : (O = E.data, l.tunnelTimeNoCSNetCost = O.baseresponse.stat.qbase_cost_time, [2, { updated: O.updated }])
                }
            })
        })
    }! function(e) { e[e.WHERE = 0] = "WHERE", e[e.DOC = 1] = "DOC" }(qe || (qe = {})),
    function(e) { e[e.STRING = 1] = "STRING", e[e.NUMBER = 2] = "NUMBER" }(ze || (ze = {})),
    function(e) { e[e.ASC = 0] = "ASC", e[e.DESC = 1] = "DESC" }(Ye || (Ye = {}));
    var Ve = function(e) {
            return function(t) {
                function r(e, n) { var r = t.call(this, n) || this; return r._internalType = ce, r.collection = e, r }
                return Object(o.c)(r, t), r.prototype.pushStage = function(e, t) { return new r(this.collection, Object(o.f)(this._stages, [new Xe(e, t)])) }, r.prototype.end = function(t) {
                    var r = this;
                    void 0 === t && (t = {});
                    var i = "collection.aggregate",
                        s = { apiStartTime: +new Date },
                        c = function() {
                            return function(e) {
                                return Object(o.b)(this, void 0, void 0, function() {
                                    var t, r, i, a, s, u, c, f, l, d, p;
                                    return Object(o.d)(this, function(o) {
                                        switch (o.label) {
                                            case 0:
                                                return t = e.env, r = e.collectionName, i = e.stages, a = e.instanceContext, s = e.timing, u = Object(h.b)() ? e.explain : void 0, c = { collection_name: r, stages: i.map(function(e) { for (var t in e) return { stage_key: t, stage_value: JSON.stringify(e[t]) }; throw new Error("empty encoded stage (" + JSON.stringify(e) + ")") }), explain: u }, f = JSON.stringify(c), s.tunnelStartTime = +new Date, [4, a.serviceContext.request({ apiName: "tcbapi_db_aggregate", serviceName: a.serviceContext.name, serializedReqData: f, requireDataNotEmpty: !0, env: t || a.serviceContext.env })];
                                            case 1:
                                                return l = o.sent(), s.tunnelEndTime = +new Date, u ? [2, n(30).EJSON.deserialize(l.data)] : (d = l.data, s.tunnelTimeNoCSNetCost = d.baseresponse.stat.qbase_cost_time, p = n(30).EJSON, [2, { list: JSON.parse(d.list).map(function(e) { return p.parse(e) }) }])
                                        }
                                    })
                                })
                            }({ env: e.database.config.env, collectionName: r.collection.collectionName, stages: e.engine.AggregateSerializer.encodeStages(r._stages), instanceContext: e, timing: s, explain: t.explain })
                        };
                    var f = Object(a.a)(t),
                        l = new Promise(function(e, n) {
                            return Object(o.b)(r, void 0, void 0, function() {
                                var r, a;
                                return Object(o.d)(this, function(f) {
                                    switch (f.label) {
                                        case 0:
                                            return f.trys.push([0, 2, 3, 4]), [4, c()];
                                        case 1:
                                            return r = f.sent(), t.explain && Object(h.b)() ? [2, e(r)] : (e({ list: r.list, errMsg: Object(p.b)(i) }), [3, 4]);
                                        case 2:
                                            return a = f.sent(), n(Object(u.g)(a, i)), [3, 4];
                                        case 3:
                                            return Object(d.b)(Object(o.a)(Object(o.a)({}, s), { apiEndTime: +new Date, apiName: "cloud.db." + i })), [7];
                                        case 4:
                                            return [2]
                                    }
                                })
                            })
                        });
                    if (!f) return l;
                    l.then(function(e) { Object(a.c)(i, t, e) }).catch(function(e) { Object(a.b)(i, t, e) })
                }, r
            }(Je)
        },
        Xe = function() { return function(e, t) { this._internalType = le, this.stage = e, this.val = t } }(),
        Je = function() {
            function e(e) { this._internalType = fe, this._stages = e }
            return e.prototype.pushStage = function(t, n) { return new e(Object(o.f)(this._stages, [new Xe(t, n)])) }, e.prototype.addFields = function(e) { return this.pushStage("addFields", e) }, e.prototype.bucket = function(e) { return this.pushStage("bucket", e) }, e.prototype.bucketAuto = function(e) { return this.pushStage("bucketAuto", e) }, e.prototype.collStats = function(e) { return this.pushStage("collStats", e) }, e.prototype.count = function(e) { return this.pushStage("count", e) }, e.prototype.facet = function(e) { return this.pushStage("facet", e) }, e.prototype.geoNear = function(e) { return this.pushStage("geoNear", e) }, e.prototype.graphLookup = function(e) { return this.pushStage("graphLookup", e) }, e.prototype.group = function(e) { return this.pushStage("group", e) }, e.prototype.indexStats = function() { return this.pushStage("indexStats", {}) }, e.prototype.limit = function(e) { return this.pushStage("limit", e) }, e.prototype.lookup = function(e) { return this.pushStage("lookup", e) }, e.prototype.match = function(e) { return this.pushStage("match", e) }, e.prototype.out = function(e) { return this.pushStage("out", e) }, e.prototype.project = function(e) { return this.pushStage("project", e) }, e.prototype.redact = function(e) { return this.pushStage("redact", e) }, e.prototype.replaceRoot = function(e) { return this.pushStage("replaceRoot", e) }, e.prototype.sample = function(e) { return this.pushStage("sample", e) }, e.prototype.skip = function(e) { return this.pushStage("skip", e) }, e.prototype.sort = function(e) { return this.pushStage("sort", e) }, e.prototype.sortByCount = function(e) { return this.pushStage("sortByCount", e) }, e.prototype.unwind = function(e) { return this.pushStage("unwind", e) }, e.prototype.end = function() {}, e
        }(),
        Qe = function(e) {
            function t(t, n) { void 0 === n && (n = !1); var r = e.call(this, t) || this; return r._sealed = n, r }
            return Object(o.c)(t, e), t.prototype.pushStage = function(e, n) { if (this._sealed) throw new Error("pushing new stage is not allowed after calling 'done()'"); return new t(Object(o.f)(this._stages, [new Xe(e, n)])) }, t.prototype.done = function() { return new t(this._stages, !0) }, t
        }(Je),
        Ze = function(e) { return e && e._internalType === fe },
        et = function(e) { return e && e._internalType === le },
        tt = new Set(["each", "position", "slice", "sort"]),
        nt = {
            eq: function(e) { return new Be(Re.EQ, [e]) },
            neq: function(e) { return new Be(Re.NEQ, [e]) },
            lt: function(e) { return new Be(Re.LT, [e]) },
            lte: function(e) { return new Be(Re.LTE, [e]) },
            gt: function(e) { return new Be(Re.GT, [e]) },
            gte: function(e) { return new Be(Re.GTE, [e]) },
            in: function(e) { return new Be(Re.IN, e) },
            nin: function(e) { return new Be(Re.NIN, e) },
            geoNear: function(e) { return new Be(Re.GEO_NEAR, [e]) },
            geoWithin: function(e) { return new Be(Re.GEO_WITHIN, [e]) },
            geoIntersects: function(e) { return new Be(Re.GEO_INTERSECTS, [e]) },
            and: function() { for (var e = [], t = 0; t < arguments.length; t++) e[t] = arguments[t]; var n = Object(f.b)(arguments[0]) ? arguments[0] : Array.from(arguments); return new Ae(se.AND, n) },
            or: function() { for (var e = [], t = 0; t < arguments.length; t++) e[t] = arguments[t]; var n = Object(f.b)(arguments[0]) ? arguments[0] : Array.from(arguments); return new Ae(se.OR, n) },
            nor: function() { for (var e = [], t = 0; t < arguments.length; t++) e[t] = arguments[t]; var n = Object(f.b)(arguments[0]) ? arguments[0] : Array.from(arguments); return new Ae(se.NOR, n) },
            not: function(e) { return new Ae(se.NOT, [e]) },
            exists: function(e) { return new Be(Re.EXISTS, [e]) },
            mod: function(e, t) { return new Be(Re.MOD, [e, t]) },
            all: function(e) { return new Be(Re.ALL, e) },
            elemMatch: function(e) { return new Be(Re.ELEM_MATCH, [e]) },
            size: function(e) { return new Be(Re.SIZE, [e]) },
            expr: function(e) { return new Be(Re.EXPR, [e]) },
            set: function(e) { return new Pe(je.SET, [e]) },
            remove: function() { return new Pe(je.REMOVE, []) },
            inc: function(e) { return new Pe(je.INC, [e]) },
            mul: function(e) { return new Pe(je.MUL, [e]) },
            min: function(e) { return new Pe(je.MIN, [e]) },
            max: function(e) { return new Pe(je.MAX, [e]) },
            rename: function(e) { return new Pe(je.RENAME, [e]) },
            bit: function(e) { return new Pe(je.BIT, [e]) },
            push: function(e) {
                var t, n, r = {};
                if (Object(f.b)(e)) r.each = e;
                else if (Object(f.g)(e) && Object(f.b)(e.each)) {
                    var i = Object.keys(e);
                    if (1 === i.length) r = e;
                    else {
                        var a = !1;
                        try { for (var s = Object(o.g)(i), u = s.next(); !u.done; u = s.next()) { var c = u.value; if (!tt.has(c)) { a = !0; break } } } catch (e) { t = { error: e } } finally { try { u && !u.done && (n = s.return) && n.call(s) } finally { if (t) throw t.error } }
                        r = a ? [e] : e
                    }
                } else r.each = [e];
                return new Pe(je.PUSH, [r])
            },
            pop: function() { return new Pe(je.POP, []) },
            shift: function() { return new Pe(je.SHIFT, []) },
            unshift: function() { for (var e = [], t = 0; t < arguments.length; t++) e[t] = arguments[t]; var n = Object(f.b)(arguments[0]) ? arguments[0] : Array.from(arguments); return new Pe(je.UNSHIFT, n) },
            addToSet: function(e) { return new Pe(je.ADD_TO_SET, [e]) },
            pull: function(e) { return new Pe(je.PULL, [e]) },
            pullAll: function(e) { return new Pe(je.PULL_ALL, [e]) },
            project: { slice: function(e) { return new Fe(ke.SLICE, [e]) } },
            aggregate: { pipeline: function() { return new Qe([]) }, abs: function(e) { return new xe(Ue.ABS, [e]) }, add: function(e) { return new xe(Ue.ADD, [e]) }, addToSet: function(e) { return new xe(Ue.ADDTOSET, [e]) }, allElementsTrue: function(e) { return new xe(Ue.ALLELEMENTSTRUE, [e]) }, and: function(e) { return new xe(Ue.AND, [e]) }, anyElementTrue: function(e) { return new xe(Ue.ANYELEMENTTRUE, [e]) }, arrayElemAt: function(e) { return new xe(Ue.ARRAYELEMAT, [e]) }, arrayToObject: function(e) { return new xe(Ue.ARRAYTOOBJECT, [e]) }, avg: function(e) { return new xe(Ue.AVG, [e]) }, ceil: function(e) { return new xe(Ue.CEIL, [e]) }, cmp: function(e) { return new xe(Ue.CMP, [e]) }, concat: function(e) { return new xe(Ue.CONCAT, [e]) }, concatArrays: function(e) { return new xe(Ue.CONCATARRAYS, [e]) }, cond: function(e) { return new xe(Ue.COND, [e]) }, convert: function(e) { return new xe(Ue.CONVERT, [e]) }, dateFromParts: function(e) { return new xe(Ue.DATEFROMPARTS, [e]) }, dateToParts: function(e) { return new xe(Ue.DATETOPARTS, [e]) }, dateFromString: function(e) { return new xe(Ue.DATEFROMSTRING, [e]) }, dateToString: function(e) { return new xe(Ue.DATETOSTRING, [e]) }, dayOfMonth: function(e) { return new xe(Ue.DAYOFMONTH, [e]) }, dayOfWeek: function(e) { return new xe(Ue.DAYOFWEEK, [e]) }, dayOfYear: function(e) { return new xe(Ue.DAYOFYEAR, [e]) }, divide: function(e) { return new xe(Ue.DIVIDE, [e]) }, eq: function(e) { return new xe(Ue.EQ, [e]) }, exp: function(e) { return new xe(Ue.EXP, [e]) }, filter: function(e) { return new xe(Ue.FILTER, [e]) }, first: function(e) { return new xe(Ue.FIRST, [e]) }, floor: function(e) { return new xe(Ue.FLOOR, [e]) }, gt: function(e) { return new xe(Ue.GT, [e]) }, gte: function(e) { return new xe(Ue.GTE, [e]) }, hour: function(e) { return new xe(Ue.HOUR, [e]) }, ifNull: function(e) { return new xe(Ue.IFNULL, [e]) }, in: function(e) { return new xe(Ue.IN, [e]) }, indexOfArray: function(e) { return new xe(Ue.INDEXOFARRAY, [e]) }, indexOfBytes: function(e) { return new xe(Ue.INDEXOFBYTES, [e]) }, indexOfCP: function(e) { return new xe(Ue.INDEXOFCP, [e]) }, isArray: function(e) { return new xe(Ue.ISARRAY, [e]) }, isoDayOfWeek: function(e) { return new xe(Ue.ISODAYOFWEEK, [e]) }, isoWeek: function(e) { return new xe(Ue.ISOWEEK, [e]) }, isoWeekYear: function(e) { return new xe(Ue.ISOWEEKYEAR, [e]) }, last: function(e) { return new xe(Ue.LAST, [e]) }, let: function(e) { return new xe(Ue.LET, [e]) }, literal: function(e) { return new xe(Ue.LITERAL, [e]) }, ln: function(e) { return new xe(Ue.LN, [e]) }, log: function(e) { return new xe(Ue.LOG, [e]) }, log10: function(e) { return new xe(Ue.LOG10, [e]) }, lt: function(e) { return new xe(Ue.LT, [e]) }, lte: function(e) { return new xe(Ue.LTE, [e]) }, ltrim: function(e) { return new xe(Ue.LTRIM, [e]) }, map: function(e) { return new xe(Ue.MAP, [e]) }, max: function(e) { return new xe(Ue.MAX, [e]) }, mergeObjects: function(e) { return new xe(Ue.MERGEOBJECTS, [e]) }, meta: function(e) { return new xe(Ue.META, [e]) }, min: function(e) { return new xe(Ue.MIN, [e]) }, millisecond: function(e) { return new xe(Ue.MILLISECOND, [e]) }, minute: function(e) { return new xe(Ue.MINUTE, [e]) }, mod: function(e) { return new xe(Ue.MOD, [e]) }, month: function(e) { return new xe(Ue.MONTH, [e]) }, multiply: function(e) { return new xe(Ue.MULTIPLY, [e]) }, neq: function(e) { return new xe(Ue.NEQ, [e]) }, not: function(e) { return new xe(Ue.NOT, [e]) }, objectToArray: function(e) { return new xe(Ue.OBJECTTOARRAY, [e]) }, or: function(e) { return new xe(Ue.OR, [e]) }, pow: function(e) { return new xe(Ue.POW, [e]) }, push: function(e) { return new xe(Ue.PUSH, [e]) }, range: function(e) { return new xe(Ue.RANGE, [e]) }, reduce: function(e) { return new xe(Ue.REDUCE, [e]) }, reverseArray: function(e) { return new xe(Ue.REVERSEARRAY, [e]) }, rtrim: function(e) { return new xe(Ue.RTRIM, [e]) }, second: function(e) { return new xe(Ue.SECOND, [e]) }, setDifference: function(e) { return new xe(Ue.SETDIFFERENCE, [e]) }, setEquals: function(e) { return new xe(Ue.SETEQUALS, [e]) }, setIntersection: function(e) { return new xe(Ue.SETINTERSECTION, [e]) }, setIsSubset: function(e) { return new xe(Ue.SETISSUBSET, [e]) }, setUnion: function(e) { return new xe(Ue.SETUNION, [e]) }, size: function(e) { return new xe(Ue.SIZE, [e]) }, slice: function(e) { return new xe(Ue.SLICE, [e]) }, split: function(e) { return new xe(Ue.SPLIT, [e]) }, sqrt: function(e) { return new xe(Ue.SQRT, [e]) }, stdDevPop: function(e) { return new xe(Ue.STDDEVPOP, [e]) }, stdDevSamp: function(e) { return new xe(Ue.STDDEVSAMP, [e]) }, strcasecmp: function(e) { return new xe(Ue.STRCASECMP, [e]) }, strLenBytes: function(e) { return new xe(Ue.STRLENBYTES, [e]) }, strLenCP: function(e) { return new xe(Ue.STRLENCP, [e]) }, substr: function(e) { return new xe(Ue.SUBSTR, [e]) }, substrBytes: function(e) { return new xe(Ue.SUBSTRBYTES, [e]) }, substrCP: function(e) { return new xe(Ue.SUBSTRCP, [e]) }, subtract: function(e) { return new xe(Ue.SUBTRACT, [e]) }, sum: function(e) { return new xe(Ue.SUM, [e]) }, switch: function(e) { return new xe(Ue.SWITCH, [e]) }, toBool: function(e) { return new xe(Ue.TOBOOL, [e]) }, toDate: function(e) { return new xe(Ue.TODATE, [e]) }, toDecimal: function(e) { return new xe(Ue.TODECIMAL, [e]) }, toDouble: function(e) { return new xe(Ue.TODOUBLE, [e]) }, toInt: function(e) { return new xe(Ue.TOINT, [e]) }, toLong: function(e) { return new xe(Ue.TOLONG, [e]) }, toObjectId: function(e) { return new xe(Ue.TOOBJECTID, [e]) }, toString: function(e) { return new xe(Ue.TOSTRING, [e]) }, toLower: function(e) { return new xe(Ue.TOLOWER, [e]) }, toUpper: function(e) { return new xe(Ue.TOUPPER, [e]) }, trim: function(e) { return new xe(Ue.TRIM, [e]) }, trunc: function(e) { return new xe(Ue.TRUNC, [e]) }, type: function(e) { return new xe(Ue.TYPE, [e]) }, week: function(e) { return new xe(Ue.WEEK, [e]) }, year: function(e) { return new xe(Ue.YEAR, [e]) }, zip: function(e) { return new xe(Ue.ZIP, [e]) } }
        };

    function rt(e) { return new it(e) }
    var it = function() {
        function e(e) { void 0 === e && (e = { offset: 0 }), Object(s.d)(e, "object", "serverDate.options"), this.options = e }
        return Object.defineProperty(e.prototype, "_internalType", { get: function() { return ve }, enumerable: !1, configurable: !0 }), e.prototype.toJSON = function() { return { $date: this.options } }, e
    }();

    function ot(e, t) { return At(e) ? mt(e) : new at(e, t) }
    var at = function() {
        function e(e, t) {
            this._internalType = ge, Object.defineProperties(this, { _internalType: { enumerable: !1, configurable: !1 } });
            var n = e,
                r = t;
            Object.defineProperties(this, { longitude: { enumerable: !0, configurable: !1, get: function() { return n }, set: function(e) { if (Object(s.d)(e, "number", "longitude"), e > 180 || e < -180) throw new u.b({ errMsg: "longitude should be a number ranges from -180 to 180" }) } }, latitude: { enumerable: !0, configurable: !1, get: function() { return r }, set: function(e) { if (Object(s.d)(e, "number", "latitude"), e > 90 || e < -90) throw new u.b({ errMsg: "latitude should be a number ranges from -90 to 90" }) } } }), this.longitude = n, this.latitude = r
        }
        return e.prototype.toJSON = function() { return function(e) { return { type: "Point", coordinates: [e.longitude, e.latitude] } }(this) }, e.prototype.toString = function() { return JSON.stringify(this.toJSON()) }, e
    }();

    function st(e) { return wt(e) ? Tt(e) : new ut(e) }
    var ut = function() {
        function e(e) { this._internalType = ye, Object.defineProperties(this, { _internalType: { enumerable: !1, configurable: !1 } }), this.points = e }
        return e.prototype.toJSON = function() { return function(e) { return { type: "MultiPoint", coordinates: e.points.map(function(e) { return [e.longitude, e.latitude] }) } }(this) }, e.prototype.toString = function() { return JSON.stringify(this.toJSON()) }, e
    }();

    function ct(e) { return Rt(e) ? vt(e) : new ft(e) }
    var ft = function() {
        function e(e) { this._internalType = Ee, Object.defineProperties(this, { _internalType: { enumerable: !1, configurable: !1 } }), this.points = e }
        return e.prototype.toJSON = function() { return function(e) { return { type: "LineString", coordinates: e.points.map(function(e) { return [e.longitude, e.latitude] }) } }(this) }, e.prototype.toString = function() { return JSON.stringify(this.toJSON()) }, e
    }();

    function lt(e) { return Ct(e) ? St(e) : new dt(e) }
    var dt = function() {
        function e(e) { this._internalType = me, Object.defineProperties(this, { _internalType: { enumerable: !1, configurable: !1 } }), this.lines = e }
        return e.prototype.toJSON = function() { return function(e) { return { type: "MultiLineString", coordinates: e.lines.map(function(e) { return e.points.map(function(e) { return [e.longitude, e.latitude] }) }) } }(this) }, e.prototype.toString = function() { return JSON.stringify(this.toJSON()) }, e
    }();

    function ht(e) { return Dt(e) ? Nt(e) : new pt(e) }
    var pt = function() {
        function e(e) { this._internalType = Oe, Object.defineProperties(this, { _internalType: { enumerable: !1, configurable: !1 } }), this.lines = e }
        return e.prototype.toJSON = function() { return function(e) { return { type: "Polygon", coordinates: e.lines.map(function(e) { return e.points.map(function(e) { return [e.longitude, e.latitude] }) }) } }(this) }, e.prototype.toString = function() { return JSON.stringify(this.toJSON()) }, e
    }();

    function _t(e) { return Bt(e) ? It(e) : new bt(e) }
    var bt = function() {
        function e(e) { this._internalType = Te, Object.defineProperties(this, { _internalType: { enumerable: !1, configurable: !1 } }), this.polygons = e }
        return e.prototype.toJSON = function() { return function(e) { return { type: "MultiPolygon", coordinates: e.polygons.map(function(e) { return e.lines.map(function(e) { return e.points.map(function(e) { return [e.longitude, e.latitude] }) }) }) } }(this) }, e.prototype.toString = function() { return JSON.stringify(this.toJSON()) }, e
    }();
    var gt, Et, Ot, yt = void 0;

    function mt(e) { return ot(e.coordinates[0], e.coordinates[1]) }

    function Tt(e) { return st(e.coordinates.map(function(e) { return ot(e[0], e[1]) })) }

    function vt(e) { return ct(e.coordinates.map(function(e) { return ot(e[0], e[1]) })) }

    function St(e) { return lt(e.coordinates.map(function(e) { return ct(e.map(function(e) { return ot(e[0], e[1]) })) })) }

    function Nt(e) { return ht(e.coordinates.map(function(e) { return ct(e.map(function(e) { return ot(e[0], e[1]) })) })) }

    function It(e) { return _t(e.coordinates.map(function(e) { return ht(e.map(function(e) { return ct(e.map(function(e) { return ot(e[0], e[1]) })) })) })) }

    function At(e) { return Object(f.g)(e) && Lt(e.coordinates) }

    function wt(e) { return Object(f.g)(e) && jt(e.coordinates) }

    function Rt(e) { return Object(f.g)(e) && Pt(e.coordinates) }

    function Ct(e) { return Object(f.g)(e) && Mt(e.coordinates) }

    function Dt(e) { return Object(f.g)(e) && Ut(e.coordinates) }

    function Bt(e) { return Object(f.g)(e) && function(e) { return Object(f.b)(e) && e.every(Ut) }(e.coordinates) }

    function Lt(e) { return Object(f.b)(e) && Object(f.f)(e[0]) && Object(f.f)(e[1]) }

    function jt(e) { return Object(f.b)(e) && e.every(Lt) }

    function Pt(e) { return jt(e) }

    function Mt(e) { return Object(f.b)(e) && e.every(Pt) }

    function Ut(e) { return Mt(e) }

    function xt(e) {
        return function e(t, n) {
            if (!Object(f.e)(t)) {
                if (Object(f.c)(t)) return { $date: +t };
                if (Object(f.j)(t)) return { $regex: t.source, $options: t.flags };
                if (Object(f.b)(t)) return t.map(function(t) { if (n.indexOf(t) > -1) throw new u.b({ errCode: _.a.SDK_DATABASE_CIRCULAR_REFERENCE, errMsg: "Cannot convert circular structure to JSON" }); return e(t, Object(o.f)(n, [t])) });
                if (Object(f.g)(t)) {
                    var r = Object(o.a)({}, t);
                    for (var i in r) {
                        if (n.indexOf(r[i]) > -1) throw new u.b({ errCode: _.a.SDK_DATABASE_CIRCULAR_REFERENCE, errMsg: "Cannot convert circular structure to JSON" });
                        r[i] = e(r[i], Object(o.f)(n, [r[i]]))
                    }
                    return r
                }
                return t
            }
            switch (t._internalType) {
                case ge:
                case ye:
                case Ee:
                case me:
                case Oe:
                case Te:
                    return t.toJSON();
                case ve:
                    return { $date: t.options };
                case Se:
                    return { $regex: t.regexp, $options: t.options };
                default:
                    return t.toJSON ? t.toJSON() : t
            }
        }(e, [e])
    }

    function $t(e, t, n, r) {
        var i = Object(o.a)({}, e);
        for (var a in e)
            if (!/^\$/.test(a)) {
                var s = e[a];
                if (s && Object(f.g)(s) && !t(s)) {
                    if (r.indexOf(s) > -1) throw new u.b({ errCode: _.a.SDK_DATABASE_CIRCULAR_REFERENCE, errMsg: "Cannot convert circular structure to JSON" });
                    var c = $t(s, t, Object(o.f)(n, [a]), Object(o.f)(r, [s]));
                    i[a] = c;
                    var l = !1;
                    for (var d in c) /^\$/.test(d) ? l = !0 : (i[a + "." + d] = c[d], delete i[a][d]);
                    l || delete i[a]
                }
            }
        return i
    }

    function kt(e) { return $t(e, qt, [], [e]) }

    function Ft(e) { return $t(e, function(e) { return !1 }, [], [e]) }

    function Wt(e, t, n) { for (var r in t[n] || delete e[n], t) e[r] ? Object(f.b)(e[r]) ? e[r].push(t[r]) : Object(f.g)(e[r]) ? Object(f.g)(t[r]) ? Object.assign(e[r], t[r]) : (console.warn("unmergable condition, query is object but condition is " + Object(f.a)(t) + ", can only overwrite", t, n), e[r] = t[r]) : (console.warn("to-merge query is of type " + Object(f.a)(e) + ", can only overwrite", e, t, n), e[r] = t[r]) : e[r] = t[r] }

    function qt(e) { return Object(f.e)(e) || Object(f.c)(e) || Object(f.j)(e) }

    function zt(e) { return xt(e) }

    function Yt(e) {
        return function(e) {
            var t = Object(o.a)({}, e);
            for (var n in t) switch (n) {
                case "$date":
                    switch (Object(f.a)(t[n])) {
                        case "number":
                            return new Date(t[n]);
                        case "object":
                            return rt(t[n])
                    }
                    break;
                case "type":
                    switch (t.coordinates, t.type) {
                        case "Point":
                            if (At(t)) return mt(t);
                            break;
                        case "MultiPoint":
                            if (wt(t)) return Tt(t);
                            break;
                        case "LineString":
                            if (Rt(t)) return vt(t);
                            break;
                        case "MultiLineString":
                            if (Ct(t)) return St(t);
                            break;
                        case "Polygon":
                            if (Dt(t)) return Nt(t);
                            break;
                        case "MultiPolygon":
                            if (Bt(t)) return It(t)
                    }
            }
            return e
        }(e)
    }

    function Gt(e, t) { return { limit: e._query.limit, offset: e._query.offset, order: function(e) { 0; return e.map(function(e) { return { field: e.fieldPath, direction: e.order === Ji.DESC ? Ye.DESC : Ye.ASC } }) }(e._query.order || []), projection: t.engine.ProjectionSerializer.encode(e._field) } }

    function Ht(e) { var t = Ft(e); for (var n in t) !0 === t[n] || 1 === t[n] ? t[n] = 1 : !1 === t[n] || 0 === t[n] ? t[n] = 0 : delete t[n]; return t }! function(e) { e.DISCONNECTED = "DISCONNECTED", e.CONNECTING = "CONNECTING", e.CONNECTED = "CONNECTED" }(Et || (Et = {})),
    function(e) { e.CONNECTION_START = "connectionStart", e.CONNECTION_SUCCESS = "connectionSuccess", e.CONNECTION_FAIL = "connectionFail", e.DISCONNECT = "disconnect" }(Ot || (Ot = {}));
    var Kt = ((gt = {})[Et.DISCONNECTED] = { transitions: [{ accept: Ot.CONNECTION_START, to: Et.CONNECTING }] }, gt[Et.CONNECTING] = { transitions: [{ accept: Ot.CONNECTION_SUCCESS, to: Et.CONNECTED }, { accept: Ot.CONNECTION_FAIL, to: Et.DISCONNECTED }, { accept: Ot.DISCONNECT, to: Et.DISCONNECTED }] }, gt[Et.CONNECTED] = { transitions: [{ accept: Ot.DISCONNECT, to: Et.DISCONNECTED }, { accept: Ot.CONNECTION_FAIL, to: Et.DISCONNECTED }] }, gt),
        Vt = n(38),
        Xt = n(16),
        Jt = n(19),
        Qt = n(14),
        Zt = "[object Symbol]";
    var en = function(e) { return "symbol" == typeof e || Object(Qt.a)(e) && Object(Jt.a)(e) == Zt },
        tn = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
        nn = /^\w*$/;
    var rn = function(e, t) { if (Object(Xt.a)(e)) return !1; var n = typeof e; return !("number" != n && "symbol" != n && "boolean" != n && null != e && !en(e)) || nn.test(e) || !tn.test(e) || null != t && e in Object(t) },
        on = n(46),
        an = "Expected a function";

    function sn(e, t) {
        if ("function" != typeof e || null != t && "function" != typeof t) throw new TypeError(an);
        var n = function() {
            var r = arguments,
                i = t ? t.apply(this, r) : r[0],
                o = n.cache;
            if (o.has(i)) return o.get(i);
            var a = e.apply(this, r);
            return n.cache = o.set(i, a) || o, a
        };
        return n.cache = new(sn.Cache || on.a), n
    }
    sn.Cache = on.a;
    var un = sn,
        cn = 500;
    var fn = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,
        ln = /\\(\\)?/g,
        dn = function(e) {
            var t = un(e, function(e) { return n.size === cn && n.clear(), e }),
                n = t.cache;
            return t
        }(function(e) { var t = []; return 46 === e.charCodeAt(0) && t.push(""), e.replace(fn, function(e, n, r, i) { t.push(r ? i.replace(ln, "$1") : n || e) }), t }),
        hn = n(20);
    var pn = function(e, t) { for (var n = -1, r = null == e ? 0 : e.length, i = Array(r); ++n < r;) i[n] = t(e[n], n, e); return i },
        _n = 1 / 0,
        bn = hn.a ? hn.a.prototype : void 0,
        gn = bn ? bn.toString : void 0;
    var En = function e(t) { if ("string" == typeof t) return t; if (Object(Xt.a)(t)) return pn(t, e) + ""; if (en(t)) return gn ? gn.call(t) : ""; var n = t + ""; return "0" == n && 1 / t == -_n ? "-0" : n };
    var On = function(e) { return null == e ? "" : En(e) };
    var yn = function(e, t) { return Object(Xt.a)(e) ? e : rn(e, t) ? [e] : dn(On(e)) },
        mn = n(40),
        Tn = n(12),
        vn = 1 / 0;
    var Sn = function(e) { if ("string" == typeof e || en(e)) return e; var t = e + ""; return "0" == t && 1 / e == -vn ? "-0" : t };
    var Nn = function(e, t, n, r) {
        if (!Object(Tn.a)(e)) return e;
        for (var i = -1, o = (t = yn(t, e)).length, a = o - 1, s = e; null != s && ++i < o;) {
            var u = Sn(t[i]),
                c = n;
            if (i != a) {
                var f = s[u];
                void 0 === (c = r ? r(f, u, s) : void 0) && (c = Object(Tn.a)(f) ? f : Object(mn.a)(t[i + 1]) ? [] : {})
            }
            Object(Vt.a)(s, u, c), s = s[u]
        }
        return e
    };
    var In = function(e, t, n) { return null == e ? e : Nn(e, t, n) };
    var An = function(e) { var t = null == e ? 0 : e.length; return t ? e[t - 1] : void 0 };
    var wn = function(e, t) { for (var n = 0, r = (t = yn(t, e)).length; null != e && n < r;) e = e[Sn(t[n++])]; return n && n == r ? e : void 0 };
    var Rn = function(e, t, n) {
        var r = -1,
            i = e.length;
        t < 0 && (t = -t > i ? 0 : i + t), (n = n > i ? i : n) < 0 && (n += i), i = t > n ? 0 : n - t >>> 0, t >>>= 0;
        for (var o = Array(i); ++r < i;) o[r] = e[r + t];
        return o
    };
    var Cn = function(e, t) { return t.length < 2 ? e : wn(e, Rn(t, 0, -1)) };
    var Dn = function(e, t) { return t = yn(t, e), null == (e = Cn(e, t)) || delete e[Sn(An(t))] };
    var Bn = function(e, t) { return null == e || Dn(e, t) },
        Ln = n(57);
    var jn = function(e, t) { for (var n = -1, r = null == e ? 0 : e.length; ++n < r && !1 !== t(e[n], n, e);); return e },
        Pn = n(21),
        Mn = n(60),
        Un = n(35),
        xn = n(54),
        $n = Object(xn.a)(Object.keys, Object),
        kn = Object.prototype.hasOwnProperty;
    var Fn = function(e) { if (!Object(Un.a)(e)) return $n(e); var t = []; for (var n in Object(e)) kn.call(e, n) && "constructor" != n && t.push(n); return t },
        Wn = n(26);
    var qn = function(e) { return Object(Wn.a)(e) ? Object(Mn.a)(e) : Fn(e) };
    var zn = function(e, t) { return e && Object(Pn.a)(t, qn(t), e) },
        Yn = n(28);
    var Gn = function(e, t) { return e && Object(Pn.a)(t, Object(Yn.a)(t), e) },
        Hn = n(53),
        Kn = n(51);
    var Vn = function(e, t) {
        for (var n = -1, r = null == e ? 0 : e.length, i = 0, o = []; ++n < r;) {
            var a = e[n];
            t(a, n, e) && (o[i++] = a)
        }
        return o
    };
    var Xn = function() { return [] },
        Jn = Object.prototype.propertyIsEnumerable,
        Qn = Object.getOwnPropertySymbols,
        Zn = Qn ? function(e) { return null == e ? [] : (e = Object(e), Vn(Qn(e), function(t) { return Jn.call(e, t) })) } : Xn;
    var er = function(e, t) { return Object(Pn.a)(e, Zn(e), t) };
    var tr = function(e, t) { for (var n = -1, r = t.length, i = e.length; ++n < r;) e[i + n] = t[n]; return e },
        nr = n(36),
        rr = Object.getOwnPropertySymbols ? function(e) { for (var t = []; e;) tr(t, Zn(e)), e = Object(nr.a)(e); return t } : Xn;
    var ir = function(e, t) { return Object(Pn.a)(e, rr(e), t) };
    var or = function(e, t, n) { var r = t(e); return Object(Xt.a)(e) ? r : tr(r, n(e)) };
    var ar = function(e) { return or(e, qn, Zn) };
    var sr = function(e) { return or(e, Yn.a, rr) },
        ur = n(17),
        cr = n(11),
        fr = Object(ur.a)(cr.a, "DataView"),
        lr = n(29),
        dr = Object(ur.a)(cr.a, "Promise"),
        hr = Object(ur.a)(cr.a, "Set"),
        pr = Object(ur.a)(cr.a, "WeakMap"),
        _r = n(24),
        br = Object(_r.a)(fr),
        gr = Object(_r.a)(lr.a),
        Er = Object(_r.a)(dr),
        Or = Object(_r.a)(hr),
        yr = Object(_r.a)(pr),
        mr = Jt.a;
    (fr && "[object DataView]" != mr(new fr(new ArrayBuffer(1))) || lr.a && "[object Map]" != mr(new lr.a) || dr && "[object Promise]" != mr(dr.resolve()) || hr && "[object Set]" != mr(new hr) || pr && "[object WeakMap]" != mr(new pr)) && (mr = function(e) {
        var t = Object(Jt.a)(e),
            n = "[object Object]" == t ? e.constructor : void 0,
            r = n ? Object(_r.a)(n) : "";
        if (r) switch (r) {
            case br:
                return "[object DataView]";
            case gr:
                return "[object Map]";
            case Er:
                return "[object Promise]";
            case Or:
                return "[object Set]";
            case yr:
                return "[object WeakMap]"
        }
        return t
    });
    var Tr = mr,
        vr = Object.prototype.hasOwnProperty;
    var Sr = function(e) {
            var t = e.length,
                n = new e.constructor(t);
            return t && "string" == typeof e[0] && vr.call(e, "index") && (n.index = e.index, n.input = e.input), n
        },
        Nr = n(41);
    var Ir = function(e, t) { var n = t ? Object(Nr.a)(e.buffer) : e.buffer; return new e.constructor(n, e.byteOffset, e.byteLength) },
        Ar = /\w*$/;
    var wr = function(e) { var t = new e.constructor(e.source, Ar.exec(e)); return t.lastIndex = e.lastIndex, t },
        Rr = hn.a ? hn.a.prototype : void 0,
        Cr = Rr ? Rr.valueOf : void 0;
    var Dr = function(e) { return Cr ? Object(Cr.call(e)) : {} },
        Br = n(56),
        Lr = "[object Boolean]",
        jr = "[object Date]",
        Pr = "[object Map]",
        Mr = "[object Number]",
        Ur = "[object RegExp]",
        xr = "[object Set]",
        $r = "[object String]",
        kr = "[object Symbol]",
        Fr = "[object ArrayBuffer]",
        Wr = "[object DataView]",
        qr = "[object Float32Array]",
        zr = "[object Float64Array]",
        Yr = "[object Int8Array]",
        Gr = "[object Int16Array]",
        Hr = "[object Int32Array]",
        Kr = "[object Uint8Array]",
        Vr = "[object Uint8ClampedArray]",
        Xr = "[object Uint16Array]",
        Jr = "[object Uint32Array]";
    var Qr = function(e, t, n) {
            var r = e.constructor;
            switch (t) {
                case Fr:
                    return Object(Nr.a)(e);
                case Lr:
                case jr:
                    return new r(+e);
                case Wr:
                    return Ir(e, n);
                case qr:
                case zr:
                case Yr:
                case Gr:
                case Hr:
                case Kr:
                case Vr:
                case Xr:
                case Jr:
                    return Object(Br.a)(e, n);
                case Pr:
                    return new r;
                case Mr:
                case $r:
                    return new r(e);
                case Ur:
                    return wr(e);
                case xr:
                    return new r;
                case kr:
                    return Dr(e)
            }
        },
        Zr = n(59),
        ei = n(34),
        ti = "[object Map]";
    var ni = function(e) { return Object(Qt.a)(e) && Tr(e) == ti },
        ri = n(39),
        ii = n(23),
        oi = ii.a && ii.a.isMap,
        ai = oi ? Object(ri.a)(oi) : ni,
        si = "[object Set]";
    var ui = function(e) { return Object(Qt.a)(e) && Tr(e) == si },
        ci = ii.a && ii.a.isSet,
        fi = ci ? Object(ri.a)(ci) : ui,
        li = 1,
        di = 2,
        hi = 4,
        pi = "[object Arguments]",
        _i = "[object Function]",
        bi = "[object GeneratorFunction]",
        gi = "[object Object]",
        Ei = {};
    Ei[pi] = Ei["[object Array]"] = Ei["[object ArrayBuffer]"] = Ei["[object DataView]"] = Ei["[object Boolean]"] = Ei["[object Date]"] = Ei["[object Float32Array]"] = Ei["[object Float64Array]"] = Ei["[object Int8Array]"] = Ei["[object Int16Array]"] = Ei["[object Int32Array]"] = Ei["[object Map]"] = Ei["[object Number]"] = Ei[gi] = Ei["[object RegExp]"] = Ei["[object Set]"] = Ei["[object String]"] = Ei["[object Symbol]"] = Ei["[object Uint8Array]"] = Ei["[object Uint8ClampedArray]"] = Ei["[object Uint16Array]"] = Ei["[object Uint32Array]"] = !0, Ei["[object Error]"] = Ei[_i] = Ei["[object WeakMap]"] = !1;
    var Oi = function e(t, n, r, i, o, a) {
            var s, u = n & li,
                c = n & di,
                f = n & hi;
            if (r && (s = o ? r(t, i, o, a) : r(t)), void 0 !== s) return s;
            if (!Object(Tn.a)(t)) return t;
            var l = Object(Xt.a)(t);
            if (l) { if (s = Sr(t), !u) return Object(Kn.a)(t, s) } else {
                var d = Tr(t),
                    h = d == _i || d == bi;
                if (Object(ei.a)(t)) return Object(Hn.a)(t, u);
                if (d == gi || d == pi || h && !o) { if (s = c || h ? {} : Object(Zr.a)(t), !u) return c ? ir(t, Gn(s, t)) : er(t, zn(s, t)) } else {
                    if (!Ei[d]) return o ? t : {};
                    s = Qr(t, d, u)
                }
            }
            a || (a = new Ln.a);
            var p = a.get(t);
            if (p) return p;
            a.set(t, s), fi(t) ? t.forEach(function(i) { s.add(e(i, n, r, i, t, a)) }) : ai(t) && t.forEach(function(i, o) { s.set(o, e(i, n, r, o, t, a)) });
            var _ = f ? c ? sr : ar : c ? keysIn : qn,
                b = l ? void 0 : _(t);
            return jn(b || t, function(i, o) { b && (i = t[o = i]), Object(Vt.a)(s, o, e(i, n, r, o, t, a)) }), s
        },
        yi = 1,
        mi = 4;
    var Ti, vi, Si, Ni = function(e) { return Oi(e, yi | mi) };
    ! function(e) { e.UNINIT = "UNINIT", e.CLOSED = "CLOSED", e.INIT_LOGGING_IN = "INIT_LOGGING_IN", e.INIT_LOGGED_IN = "INIT_LOGGED_IN", e.INIT_LOGIN_FAIL = "INIT_LOGIN_FAIL", e.INIT_WATCH_PENDING = "INIT_WATCH_PENDING", e.INIT_WATCH_FAIL = "INIT_WATCH_FAIL", e.INIT_WATCH_SUCCESS = "INIT_WATCH_SUCCESS", e.PAUSED = "PAUSED", e.ABNORMAL_WATCH_STATUS = "ABNORMAL_WATCH_STATUS", e.REBUILD_LOGGING_IN = "REBUILD_LOGGING_IN", e.REBUILD_LOGGED_IN = "REBUILD_LOGGED_IN", e.REBUILD_LOGIN_FAIL = "REBUILD_LOGIN_FAIL", e.REBUILD_WATCH_PENDING = "REBUILD_WATCH_PENDING", e.REBUILD_WATCH_FAIL = "REBUILD_WATCH_FAIL", e.REBUILD_WATCH_SUCCESS = "REBUILD_WATCH_SUCCESS" }(vi || (vi = {})),
    function(e) { e.CLOSE = "close", e.LOGIN_START = "loginStart", e.LOGIN_FAIL = "loginFail", e.LOGIN_SUCCESS = "loginSuccess", e.INIT_WATCH_START = "initWatchStart", e.INIT_WATCH_FAIL = "initWatchFail", e.INIT_WATCH_SUCCESS = "initWatchSuccess", e.WS_DISCONNECTED = "wsDisconnected", e.WS_CONNECTED = "wsConnected", e.REBUILD_WATCH_START = "rebuildWatchStart", e.REBUILD_WATCH_FAIL = "rebuildWatchFail", e.REBUILD_WATCH_SUCCESS = "rebuildWatchSuccess", e.NEED_REBUILD_WATCH = "needRebuildWatch" }(Si || (Si = {}));
    var Ii = { accept: Si.CLOSE, to: vi.CLOSED },
        Ai = { accept: Si.WS_DISCONNECTED, to: vi.CLOSED },
        wi = { accept: Si.WS_DISCONNECTED, to: vi.PAUSED },
        Ri = ((Ti = {})[vi.UNINIT] = { transitions: [{ accept: Si.LOGIN_START, to: vi.INIT_LOGGING_IN }, Ai, Ii] }, Ti[vi.CLOSED] = { transitions: [Ii] }, Ti[vi.INIT_LOGGING_IN] = { transitions: [{ accept: Si.LOGIN_FAIL, to: vi.INIT_LOGIN_FAIL }, { accept: Si.LOGIN_SUCCESS, to: vi.INIT_LOGGED_IN }, Ai, Ii] }, Ti[vi.INIT_LOGIN_FAIL] = { transitions: [{ accept: Si.LOGIN_START, to: vi.INIT_LOGGING_IN }, Ai, Ii] }, Ti[vi.INIT_LOGGED_IN] = { transitions: [{ accept: Si.INIT_WATCH_START, to: vi.INIT_WATCH_PENDING }, Ai, Ii] }, Ti[vi.INIT_WATCH_PENDING] = { transitions: [{ accept: Si.INIT_WATCH_FAIL, to: vi.INIT_WATCH_FAIL }, { accept: Si.INIT_WATCH_SUCCESS, to: vi.INIT_WATCH_SUCCESS }, Ai, Ii] }, Ti[vi.INIT_WATCH_FAIL] = { transitions: [{ accept: Si.LOGIN_START, to: vi.INIT_LOGGING_IN }, Ai, Ii] }, Ti[vi.INIT_WATCH_SUCCESS] = { transitions: [{ accept: Si.WS_DISCONNECTED, to: vi.PAUSED }, { accept: Si.NEED_REBUILD_WATCH, to: vi.ABNORMAL_WATCH_STATUS }, wi, Ii] }, Ti[vi.PAUSED] = { transitions: [{ accept: Si.LOGIN_START, to: vi.REBUILD_LOGGING_IN }, wi, Ii] }, Ti[vi.ABNORMAL_WATCH_STATUS] = { transitions: [{ accept: Si.LOGIN_START, to: vi.REBUILD_LOGGING_IN }, wi, Ii] }, Ti[vi.REBUILD_LOGGING_IN] = { transitions: [{ accept: Si.LOGIN_FAIL, to: vi.REBUILD_LOGIN_FAIL }, { accept: Si.LOGIN_SUCCESS, to: vi.REBUILD_LOGGED_IN }, wi, Ii] }, Ti[vi.REBUILD_LOGIN_FAIL] = { transitions: [{ accept: Si.LOGIN_START, to: vi.REBUILD_LOGGING_IN }, wi, Ii] }, Ti[vi.REBUILD_LOGGED_IN] = { transitions: [{ accept: Si.REBUILD_WATCH_START, to: vi.REBUILD_WATCH_PENDING }, wi, Ii] }, Ti[vi.REBUILD_WATCH_PENDING] = { transitions: [{ accept: Si.REBUILD_WATCH_FAIL, to: vi.REBUILD_WATCH_FAIL }, { accept: Si.REBUILD_WATCH_SUCCESS, to: vi.REBUILD_WATCH_SUCCESS }, wi, Ii] }, Ti[vi.REBUILD_WATCH_FAIL] = { transitions: [{ accept: Si.LOGIN_START, to: vi.REBUILD_LOGGING_IN }, wi, Ii] }, Ti[vi.REBUILD_WATCH_SUCCESS] = { transitions: [{ accept: Si.NEED_REBUILD_WATCH, to: vi.ABNORMAL_WATCH_STATUS }, wi, Ii] }, Ti),
        Ci = function() {
            function e(e) {
                for (var t in this.listeners = new Set, this.currentState = e.initialState, this.states = new Map, e.states) this.states.set(t, { name: t, transitions: new Map(e.states[t].transitions.map(function(e) { return [e.accept, e.to] })) });
                this.history = { options: { enable: !1, limit: 100 }, transitions: [] }, e.history && ("boolean" == typeof e.history ? e.history && (this.history.options.enable = !0) : Boolean(e.history.enable) && (void 0 === e.history.limit || null === e.history.limit ? this.history.options = { enable: !0, limit: 100 } : e.history.limit > 0 && (this.history.options = { enable: !0, limit: e.history.limit }))), this.history.options.enable && this.history.transitions.push({ state: this.currentState })
            }
            return e.prototype.transition = function(e, t) {
                var n = this;
                if (t && (t instanceof Set ? !t.has(this.currentState) : t !== this.currentState)) throw new Di("current state (" + this.currentState + ") != expected from state (" + (t instanceof Set ? JSON.stringify(Object(o.f)(t)) : t) + ")", "unexpectedFromState");
                var r = "string" == typeof e ? { type: e } : e,
                    i = this.states.get(this.currentState),
                    a = i.transitions.get(r.type);
                if (!a) throw new Di("current state (" + this.currentState + ') does not accept "' + r.type + '"', "unexpectedInput");
                this.currentState = a, this.history.options.enable && (this.history.transitions.push({ event: r.type, state: this.currentState }), this.history.transitions.length > this.history.options.limit && (this.history.transitions.length === this.history.options.limit + 1 ? this.history.transitions.shift() : this.history.transitions.splice(0, this.history.transitions.length - this.history.options.limit))), this.listeners.forEach(function(e) { try { e({ event: r, from: i.name, to: n.currentState }) } catch (e) { console.error("FSM listener exec error: ", e) } })
            }, e.prototype.canAccept = function(e) { return this.states.get(this.currentState).transitions.has(e) }, e.prototype.subscribe = function(e) { this.listeners.add(e) }, e.prototype.unsubscribe = function(e) { this.listeners.delete(e) }, e.prototype.getHistoryRepresentation = function(e) {
                return this.history.options.enable ? "states: " + (e.limit ? this.history.transitions.slice(-e.limit) : this.history.transitions).map(function(e) {
                    var t = e.state,
                        n = e.event;
                    return (n ? "-(" + n + ")->" : "") + t
                }).join("") : ""
            }, e
        }(),
        Di = function(e) {
            function t(t, n, r) { var i = e.call(this, t) || this; return i.type = "transition", i.generic = !0, i.subtype = n, i.payload = r, i }
            return Object(o.c)(t, e), t
        }(Error);

    function Bi(e) { return void 0 === e && (e = ""), (e ? e + "_" : "") + +new Date + "_" + Math.random() }
    var Li = n(18),
        ji = 1128,
        Pi = { REALTIME_DB_INIT_WS_SUCCESS: 1, REALTIME_DB_INIT_WS_FAIL: 2, REALTIME_DB_RECONNECT_WS_SUCCESS: 3, REALTIME_DB_RECONNECT_WS_FAIL: 4, REALTIME_DB_INIT_WATCH_SUCCESS: 5, REALTIME_DB_INIT_WATCH_FAIL: 6, REALTIME_DB_REBUILD_WATCH_SUCCESS: 7, REALTIME_DB_REBUILD_WATCH_FAIL: 8, REALTIME_DB_WS_ONERROR_BEFORE_OPEN: 9, REALTIME_DB_WS_ONERROR_WHILE_ACTIVE: 10, REALTIME_DB_WS_ONCLOSE: 11, REALTIME_DB_WS_ONCLOSE_HEARTBEAT_PING_FAIL: 12, REALTIME_DB_WS_ONCLOSE_HEARTBEAT_PONG_TIMEOUT: 13, REALTIME_DB_WS_ONCLOSE_AB_NORMAL_CLOSURE: 14, REALTIME_DB_WS_ONCLOSE_SERVER_CLOSE_NO_AUTH: 15, REALTIME_DB_WS_ONCLOSE_UNKNOWN_ORIGIN: 16, REALTIME_DB_WS_TOTAL_CONNECTION_TIMEOUT: 17, REALTIME_DB_WS_ONCLOSE_SERVER_CLOSE_FOR_UPGRADE: 18, REALTIME_DB_RECV_MSG_WITH_CLOSED_WATCHID: 30, REALTIME_DB_RECV_MSG_WITH_UNKNOWN_WATCHID: 31, REALTIME_DB_RECV_MSG_WITHOUT_WATCHID: 32, REALTIME_DB_HANDLE_EVENT_ERROR: 33, REALTIME_DB_RECV_DUPLICATE_EVENT: 34, REALTIME_DB_RECV_DUPLICATE_EVENT_AND_EVENT_OUT_OF_ORDER: 35, REALTIME_DB_UNEXPECTED_EVENT_DATATYPE_UPDATE_NO_ASSOCIATED_DOC: 36, REALTIME_DB_UNEXPECTED_EVENT_REMOVE_NO_ASSOCIATED_DOC: 37, REALTIME_DB_UNEXPECTED_EVENT_DEQUEUE_NO_ASSOCIATED_DOC: 38, REALTIME_DB_UNEXPECTED_EVENT_QUEUETYPE_UPDATE_NO_ASSOCIATED_DOC: 39, REALTIME_DB_EVENT_OUT_OF_ORDER: 40, REALTIME_DB_INIT_WATCH_FAIL_SERVER_SIGN_ERROR: 50, REALTIME_DB_REBUILD_WATCH_FAIL_SERVER_SIGN_ERROR: 51, REALTIME_DB_INIT_WATCH_FAIL_SERVER_OTHER_ERROR: 52, REALTIME_DB_REBUILD_WATCH_FAIL_SERVER_OTHER_ERROR: 53, REALTIME_DB_INIT_WATCH_FAIL_TIMEOUT_ERROR_TOTAL_CONNECTION: 54, REALTIME_DB_REBUILD_WATCH_FAIL_TIMEOUT_ERROR_TOTAL_CONNECTION: 55, REALTIME_DB_REBUILD_WATCH_FAIL_TIMEOUT_ERROR_QUERY_EVENT_CACHE: 56, REALTIME_DB_INIT_WATCH_FAIL_CANCELLED_ERROR: 57, REALTIME_DB_REBUILD_WATCH_FAIL_CANCELLED_ERROR: 58, REALTIME_DB_INIT_WATCH_FAIL_UNKNOWN_ERROR: 59, REALTIME_DB_REBUILD_WATCH_FAIL_UNKNOWN_ERROR: 60 },
        Mi = function() { return function(e) { this.close = e.close, this.onChange = e.onChange, this.onError = e.onError, e.debug && Object.defineProperty(this, "virtualClient", { get: function() { return e.virtualClient } }) } }(),
        Ui = function() {
            return function(e) {
                var t = e.id,
                    n = e.docChanges,
                    r = e.docs,
                    i = e.type,
                    o = (e.EJSON, e.requestId),
                    a = e.watchId;
                Object.defineProperties(this, { id: { get: function() { return t }, enumerable: !0 }, docChanges: { get: function() { return n }, enumerable: !0 }, docs: { get: function() { return r }, enumerable: !0 }, type: { get: function() { return i }, enumerable: !0 } }), this.requestId = o, this.watchId = a
            }
        }(),
        xi = function(e) {
            function t(t) { var n = e.call(this, "Watch Error " + JSON.stringify(t.msgData) + " (requestid: " + t.requestId + ")") || this; return n.isRealtimeErrorMessageError = !0, n.payload = t, n }
            return Object(o.c)(t, e), t
        }(Error),
        $i = function(e) { return e && e.isRealtimeErrorMessageError },
        ki = 2,
        Fi = 2,
        Wi = 1e4,
        qi = 1e4,
        zi = 1e4,
        Yi = new Set([vi.REBUILD_LOGGING_IN, vi.INIT_LOGGING_IN]),
        Gi = function(e) { 0 },
        Hi = function() {
            function e(e) {
                var t = this;
                this.closeWatchInvoked = !1, this.userOnErrorInvoked = !1, this._loginInvalidated = !1, this._errors = [], this._snapshotHistory = [], this._login = function(e) {
                    return Object(o.b)(t, void 0, void 0, function() {
                        var t, n;
                        return Object(o.d)(this, function(r) {
                            switch (r.label) {
                                case 0:
                                    this._fsm.transition(Si.LOGIN_START), r.label = 1;
                                case 1:
                                    return r.trys.push([1, 3, , 4]), [4, this.login(this.envId, e || this._loginInvalidated, this.timing)];
                                case 2:
                                    return t = r.sent(), this.envId || (this.envId = t.envId), this._fsm.transition(Si.LOGIN_SUCCESS, Yi), this._loginInvalidated = !1, [3, 4];
                                case 3:
                                    n = r.sent(), this._errors.push(n), this._loginInvalidated = !0;
                                    try { this._fsm.transition(Si.LOGIN_FAIL, Yi) } catch (e) { console.warn("[realtime]", e) }
                                    return [3, 4];
                                case 4:
                                    return [2]
                            }
                        })
                    })
                }, this.initWatch = function() {
                    return Object(o.b)(t, void 0, void 0, function() {
                        var e, t, n, r, i, a, s, u, c, f, l, h, p, _, b = this;
                        return Object(o.d)(this, function(g) {
                            switch (g.label) {
                                case 0:
                                    e = Date.now(), t = Bi(), g.label = 1;
                                case 1:
                                    return g.trys.push([1, 3, , 4]), this._fsm.transition(Si.INIT_WATCH_START, vi.INIT_LOGGED_IN), n = this.envId, r = { watchId: this.watchId, requestId: t, msgType: "INIT_WATCH", msgData: { envId: n, collName: this.collectionName, query: this.query, limit: this.limit, orderBy: this.orderBy, queryType: this.queryType } }, [4, this.send({ msg: r, waitResponse: !0, skipOnMessage: !0, timeout: qi })];
                                case 2:
                                    if (i = g.sent(), this.assertAsyncTaskStatus(), a = i.msgData, s = a.events, u = a.currEvent, this.sessionInfo = { queryID: i.msgData.queryID, currentEventId: u - 1, currentDocs: [], currentEventTS: Date.now() }, s.length > 0) {
                                        try { for (c = Object(o.g)(s), f = c.next(); !f.done; f = c.next()) f.value.ID = u } catch (e) { p = { error: e } } finally { try { f && !f.done && (_ = c.return) && _.call(c) } finally { if (p) throw p.error } }
                                        this.handleServerEvents(i)
                                    } else this.sessionInfo.currentEventId = u, l = new Ui({ id: u, docChanges: [], docs: [], type: "init", EJSON: this.getEJSON(), requestId: i.requestId, watchId: this.watchId }), Li.a.surroundThirdByTryCatch(function() { return b.listener.onChange(l) })(), this.scheduleSendACK(), this.debug && this._snapshotHistory.push(l);
                                    return this.onWatchStart(this, this.sessionInfo.queryID), this._availableRetries.INIT_WATCH = ki, this._wsDisconnectionTS = void 0, Object(d.c)(ji, Pi.REALTIME_DB_INIT_WATCH_SUCCESS, !0), Object(d.b)({ apiName: "_realtime.initWatch(success)", apiStartTime: e, apiEndTime: Date.now() }), this._fsm.transition(Si.INIT_WATCH_SUCCESS), [3, 4];
                                case 3:
                                    return h = g.sent(), Object(d.b)({ apiName: "_realtime.initWatch(fail)", apiStartTime: e, apiEndTime: Date.now() }), this.handleWatchEstablishmentError(h, { operationName: "INIT_WATCH", requestId: t }), [3, 4];
                                case 4:
                                    return [2]
                            }
                        })
                    })
                }, this.rebuildWatch = function() {
                    return Object(o.b)(t, void 0, void 0, function() {
                        var e, t, n, r, i, a;
                        return Object(o.d)(this, function(o) {
                            switch (o.label) {
                                case 0:
                                    e = Date.now(), t = Bi(), o.label = 1;
                                case 1:
                                    if (o.trys.push([1, 4, , 5]), this._fsm.transition(Si.REBUILD_WATCH_START, vi.REBUILD_LOGGED_IN), n = this.envId, !this.sessionInfo) throw new Error("can not rebuildWatch without a successful initWatch (lack of sessionInfo)");
                                    if (this._wsDisconnectionTS && Date.now() - this._wsDisconnectionTS > .9 * this.getServiceContext().appConfig.realtimeQueryEventCacheTimeout) throw new u.c("query event cache timeout, ws has been disconnected for too long, PLEASE RECONNECT manually", { subtype: "queryEventCacheClientTimeout", retryable: !1 });
                                    return r = { watchId: this.watchId, requestId: t, msgType: "REBUILD_WATCH", msgData: { envId: n, collName: this.collectionName, queryID: this.sessionInfo.queryID, eventID: this.sessionInfo.currentEventId } }, [4, this.send({ msg: r, waitResponse: !0, skipOnMessage: !0, timeout: zi })];
                                case 2:
                                    return i = o.sent(), this.assertAsyncTaskStatus(), [4, this.handleServerEvents(i)];
                                case 3:
                                    return o.sent(), this._availableRetries.REBUILD_WATCH = ki, this._wsDisconnectionTS = void 0, Object(d.c)(ji, Pi.REALTIME_DB_REBUILD_WATCH_SUCCESS, !0), Object(d.b)({ apiName: "_realtime.rebuildWatch(success)", apiStartTime: e, apiEndTime: Date.now() }), this._fsm.transition(Si.REBUILD_WATCH_SUCCESS), [3, 5];
                                case 4:
                                    return a = o.sent(), Object(d.b)({ apiName: "_realtime.rebuildWatch(fail)", apiStartTime: e, apiEndTime: Date.now() }), this.handleWatchEstablishmentError(a, { operationName: "REBUILD_WATCH", requestId: t }), [3, 5];
                                case 5:
                                    return [2]
                            }
                        })
                    })
                }, this.handleWatchEstablishmentError = function(e, n) {
                    return Object(o.b)(t, void 0, void 0, function() {
                        var t, r, i = this;
                        return Object(o.d)(this, function(o) {
                            return t = "INIT_WATCH" === n.operationName, r = function(r) {
                                var o = (r || e) + " (" + (t ? "initWatch" : "rebuildWatch") + " requestId " + n.requestId + ")";
                                if (i.closeWithError(new u.b({ errCode: t ? _.a.SDK_DATABASE_REALTIME_LISTENER_INIT_WATCH_FAIL : _.a.SDK_DATABASE_REALTIME_LISTENER_REBUILD_WATCH_FAIL, errMsg: o })), Object(d.c)(ji, t ? Pi.REALTIME_DB_INIT_WATCH_FAIL : Pi.REALTIME_DB_REBUILD_WATCH_FAIL, !0), !$i(e)) {
                                    if (Object(u.f)(e)) {
                                        switch (e.payload.subtype) {
                                            case "totalConnectionTimeout":
                                                Object(d.c)(ji, t ? Pi.REALTIME_DB_INIT_WATCH_FAIL_TIMEOUT_ERROR_TOTAL_CONNECTION : Pi.REALTIME_DB_REBUILD_WATCH_FAIL_TIMEOUT_ERROR_TOTAL_CONNECTION, !0);
                                                break;
                                            case "queryEventCacheClientTimeout":
                                                t || Object(d.c)(ji, Pi.REALTIME_DB_REBUILD_WATCH_FAIL_TIMEOUT_ERROR_QUERY_EVENT_CACHE, !0)
                                        }
                                        return
                                    }
                                    return Object(u.d)(e) ? void Object(d.c)(ji, t ? Pi.REALTIME_DB_INIT_WATCH_FAIL_CANCELLED_ERROR : Pi.REALTIME_DB_REBUILD_WATCH_FAIL_CANCELLED_ERROR, !0) : void Object(d.c)(ji, t ? Pi.REALTIME_DB_INIT_WATCH_FAIL_UNKNOWN_ERROR : Pi.REALTIME_DB_REBUILD_WATCH_FAIL_UNKNOWN_ERROR, !0)
                                }
                                switch (e.payload.msgData.code) {
                                    case "CHECK_LOGIN_FAILED":
                                    case "SIGN_EXPIRED_ERROR":
                                    case "SIGN_INVALID_ERROR":
                                    case "SIGN_PARAM_INVALID":
                                        Object(d.c)(ji, t ? Pi.REALTIME_DB_INIT_WATCH_FAIL_SERVER_SIGN_ERROR : Pi.REALTIME_DB_REBUILD_WATCH_FAIL_SERVER_SIGN_ERROR, !0);
                                        break;
                                    default:
                                        Object(d.c)(ji, t ? Pi.REALTIME_DB_INIT_WATCH_FAIL_SERVER_OTHER_ERROR : Pi.REALTIME_DB_REBUILD_WATCH_FAIL_SERVER_OTHER_ERROR, !0)
                                }
                            }, this._errors.push(e), this.handleCommonError(e, { onSignError: function() { i._loginInvalidated = !0, i._fsm.transition(i.initialized ? Si.REBUILD_WATCH_FAIL : Si.INIT_WATCH_FAIL) }, onTimeoutError: function(e) { e.payload && !e.payload.retryable ? r(e) : i._fsm.transition(i.initialized ? Si.REBUILD_WATCH_FAIL : Si.INIT_WATCH_FAIL) }, onNotRetryableError: r, onCancelledError: function(e) { i._fsm.transition(i.initialized ? Si.REBUILD_WATCH_FAIL : Si.INIT_WATCH_FAIL) }, onUnknownError: function() { i._fsm.transition(i.initialized ? Si.REBUILD_WATCH_FAIL : Si.INIT_WATCH_FAIL) } }), [2]
                        })
                    })
                }, this.closeWatch = function() {
                    return Object(o.b)(t, void 0, void 0, function() {
                        var e, t;
                        return Object(o.d)(this, function(n) {
                            switch (n.label) {
                                case 0:
                                    if (this.closeWatchInvoked = !0, e = this.sessionInfo ? this.sessionInfo.queryID : "", this._fsm.currentState === vi.CLOSED) return [2];
                                    n.label = 1;
                                case 1:
                                    return n.trys.push([1, 3, 4, 5]), this._fsm.transition(Si.CLOSE), [4, this.sendCloseWatch()];
                                case 2:
                                    return n.sent(), [3, 5];
                                case 3:
                                    return t = n.sent(), console.warn("[realtime] non-fatal error while closing watch: " + t), [3, 5];
                                case 4:
                                    return this.sessionInfo = void 0, this.onWatchClose(this, e), this._cleanup(), [7];
                                case 5:
                                    return [2]
                            }
                        })
                    })
                }, this.sendCloseWatch = function() {
                    return Object(o.b)(t, void 0, void 0, function() {
                        var e;
                        return Object(o.d)(this, function(t) {
                            switch (t.label) {
                                case 0:
                                    return e = { watchId: this.watchId, requestId: Bi(), msgType: "CLOSE_WATCH", msgData: null }, [4, this.send({ msg: e })];
                                case 1:
                                    return t.sent(), [2]
                            }
                        })
                    })
                }, this.scheduleSendACK = function() { t.clearACKSchedule(), t._ackTimeoutId = setTimeout(function() { t._waitExpectedTimeoutId ? t.scheduleSendACK() : t.sendACK() }, Wi) }, this.clearACKSchedule = function() { t._ackTimeoutId && clearTimeout(t._ackTimeoutId) }, this.sendACK = function() {
                    return Object(o.b)(t, void 0, void 0, function() {
                        var e, t, n;
                        return Object(o.d)(this, function(r) {
                            switch (r.label) {
                                case 0:
                                    return r.trys.push([0, 2, , 3]), this._fsm.currentState !== vi.INIT_WATCH_SUCCESS && this._fsm.currentState !== vi.REBUILD_WATCH_SUCCESS ? (this.scheduleSendACK(), [2]) : this.sessionInfo ? (e = { watchId: this.watchId, requestId: Bi(), msgType: "CHECK_LAST", msgData: { queryID: this.sessionInfo.queryID, eventID: this.sessionInfo.currentEventId } }, [4, this.send({ msg: e })]) : (console.warn("[realtime listener] can not send ack without a successful initWatch (lack of sessionInfo)"), [2]);
                                case 1:
                                    return r.sent(), this.scheduleSendACK(), [3, 3];
                                case 2:
                                    if (t = r.sent(), $i(t)) switch ((n = t.payload).msgData.code) {
                                        case "CHECK_LOGIN_FAILED":
                                        case "SIGN_EXPIRED_ERROR":
                                        case "SIGN_INVALID_ERROR":
                                        case "SIGN_PARAM_INVALID":
                                            return this._loginInvalidated = !0, this._fsm.currentState !== vi.INIT_WATCH_SUCCESS && this._fsm.currentState !== vi.REBUILD_WATCH_SUCCESS || this._fsm.transition(Si.NEED_REBUILD_WATCH), [2];
                                        case "QUERYID_INVALID_ERROR":
                                        case "SYS_ERR":
                                        case "INVALIID_ENV":
                                        case "COLLECTION_PERMISSION_DENIED":
                                            return this.closeWithError(new u.b({ errCode: _.a.SDK_DATABASE_REALTIME_LISTENER_CHECK_LAST_FAIL, errMsg: n.msgData.code })), [2]
                                    }
                                    return this._availableRetries.CHECK_LAST && this._availableRetries.CHECK_LAST > 0 ? (this._availableRetries.CHECK_LAST--, this.scheduleSendACK()) : this.closeWithError(new u.b({ errCode: _.a.SDK_DATABASE_REALTIME_LISTENER_CHECK_LAST_FAIL, errMsg: t })), [3, 3];
                                case 3:
                                    return [2]
                            }
                        })
                    })
                }, this.handleCommonError = function(e, t) {
                    if ($i(e)) {
                        switch (e.payload.msgData.code) {
                            case "CHECK_LOGIN_FAILED":
                            case "SIGN_EXPIRED_ERROR":
                            case "SIGN_INVALID_ERROR":
                            case "SIGN_PARAM_INVALID":
                                return void t.onSignError(e);
                            case "QUERYID_INVALID_ERROR":
                            case "SYS_ERR":
                            case "INVALIID_ENV":
                            case "COLLECTION_PERMISSION_DENIED":
                            default:
                                return void t.onNotRetryableError(e)
                        }
                    } else { if (Object(u.f)(e)) return void t.onTimeoutError(e); if (Object(u.d)(e)) return void t.onCancelledError(e) }
                    t.onUnknownError(e)
                }, this.watchId = "watchid_" + +new Date + "_" + Math.random(), this._parentFSM = e.parentFSM, this.envId = e.envId, this.collectionName = e.collectionName, this.query = e.query, this.limit = e.limit, this.orderBy = e.orderBy, this.queryType = e.queryType, this.send = e.send, this.login = e.login, this.isWSConnected = e.isWSConnected, this.getWaitExpectedTimeoutLength = e.getWaitExpectedTimeoutLength, this.getEJSON = e.getEJSON, this.getServiceContext = e.getServiceContext, this.onWatchStart = e.onWatchStart, this.onWatchClose = e.onWatchClose, this.timing = e.timing, this.debug = e.debug, this._availableRetries = { INIT_WATCH: ki, REBUILD_WATCH: ki, CHECK_LAST: Fi }, this._fsm = new Ci({ initialState: vi.UNINIT, states: Ri, history: !0 }), this._subscribeParentFSMEvents(), this._subscribeFSMEvents(), this.listener = new Mi({ close: this.closeWatch, onChange: e.onChange, onError: e.onError, debug: this.debug, virtualClient: this }), this._parentFSM.currentState === Et.CONNECTED && this._login(), e.debug && (this.wsclient = e.wsclient)
            }
            return Object.defineProperty(e.prototype, "initialized", { get: function() { return Boolean(this.sessionInfo) }, enumerable: !1, configurable: !0 }), e.prototype._cleanup = function() { this._parentFSM.unsubscribe(this._parentFSMListener) }, e.prototype._subscribeParentFSMEvents = function() {
                var e = this;
                this._parentFSMListener = function(t) {
                    var n = t.event;
                    t.from, t.to;
                    if (e._fsm.currentState !== vi.CLOSED)
                        if (n.type === Ot.DISCONNECT || n.type === Ot.CONNECTION_FAIL) switch (e._fsm.currentState) {
                            case vi.UNINIT:
                            case vi.INIT_LOGGING_IN:
                            case vi.INIT_LOGIN_FAIL:
                            case vi.INIT_LOGGED_IN:
                            case vi.INIT_WATCH_PENDING:
                            case vi.INIT_WATCH_FAIL:
                                e.closeWithError(n.error || new Error("websocket connection fail"), !1);
                                break;
                            default:
                                n.type === Ot.DISCONNECT ? (e._wsDisconnectionTS || (e._wsDisconnectionTS = Date.now()), e._fsm.transition(Si.WS_DISCONNECTED)) : e.closeWithError(n.error || new Error("websocket connection fail"), !1)
                        } else if (n.type === Ot.CONNECTION_SUCCESS) switch (e._fsm.currentState) {
                            case vi.UNINIT:
                            case vi.PAUSED:
                                e._login();
                                break;
                            case vi.CLOSED:
                                break;
                            default:
                                console.warn("[realtime] current state should not be " + e._fsm.currentState + " (parent event " + n + ")")
                        }
                }, this._parentFSM.subscribe(this._parentFSMListener)
            }, e.prototype._subscribeFSMEvents = function() {
                var e = this;
                this._FSMListener = function(t) {
                    var n = t.event,
                        r = t.from;
                    t.to;
                    switch (n.type) {
                        case Si.WS_CONNECTED:
                            e._login().catch(Gi);
                            break;
                        case Si.LOGIN_SUCCESS:
                            r === vi.INIT_LOGGING_IN ? e.initWatch().catch(Gi) : r === vi.REBUILD_LOGGING_IN ? e.rebuildWatch().catch(Gi) : e.closeWithError(new u.b({ errCode: _.a.SDK_DATABASE_REALTIME_LISTENER_UNEXPECTED_FATAL_ERROR, errMsg: "unexpected state: event " + n.type + " from " + r }));
                            break;
                        case Si.LOGIN_FAIL:
                            r === vi.INIT_LOGGING_IN ? e.useRetryTicket("INIT_WATCH") ? e._login().catch(Gi) : e.closeWithError(new u.b({ errCode: _.a.SDK_DATABASE_REALTIME_LISTENER_INIT_WATCH_FAIL, errMsg: "login fail " + e._errors[e._errors.length - 1] })) : r === vi.REBUILD_LOGGING_IN ? e.useRetryTicket("REBUILD_WATCH") ? e._login().catch(Gi) : e.closeWithError(new u.b({ errCode: _.a.SDK_DATABASE_REALTIME_LISTENER_REBUILD_WATCH_FAIL, errMsg: "login fail " + e._errors[e._errors.length - 1] })) : e.closeWithError(new u.b({ errCode: _.a.SDK_DATABASE_REALTIME_LISTENER_UNEXPECTED_FATAL_ERROR, errMsg: "unexpected state: event " + n.type + " from " + r }));
                            break;
                        case Si.INIT_WATCH_SUCCESS:
                            e._availableRetries.INIT_WATCH = ki, e._errors = [];
                            break;
                        case Si.INIT_WATCH_FAIL:
                            e.useRetryTicket("INIT_WATCH") ? e._login().catch(Gi) : e.closeWithError(new u.b({ errCode: _.a.SDK_DATABASE_REALTIME_LISTENER_INIT_WATCH_FAIL, errMsg: "init watch fail " + e._errors[e._errors.length - 1] }));
                            break;
                        case Si.REBUILD_WATCH_SUCCESS:
                            e._availableRetries.REBUILD_WATCH = ki, e._errors = [];
                            break;
                        case Si.REBUILD_WATCH_FAIL:
                            e.useRetryTicket("REBUILD_WATCH") ? e._login().catch(Gi) : e.closeWithError(new u.b({ errCode: _.a.SDK_DATABASE_REALTIME_LISTENER_REBUILD_WATCH_FAIL, errMsg: "init watch fail " + e._errors[e._errors.length - 1] }));
                            break;
                        case Si.NEED_REBUILD_WATCH:
                            e._login().catch(Gi)
                    }
                }, this._fsm.subscribe(this._FSMListener)
            }, e.prototype.useRetryTicket = function(e) { return !!(this._availableRetries[e] && this._availableRetries[e] > 0) && (this._availableRetries[e]--, !0) }, e.prototype.assertAsyncTaskStatus = function() {
                if (this.closeWatchInvoked) throw new u.a("closeWatch", { subtype: "closeWatch" });
                switch (this._fsm.currentState) {
                    case vi.PAUSED:
                        throw new u.a("pause", { subtype: "pause" });
                    case vi.CLOSED:
                        throw new u.a("close", { subtype: "close" })
                }
            }, e.prototype.handleServerEvents = function(e) {
                return Object(o.b)(this, void 0, void 0, function() {
                    var t;
                    return Object(o.d)(this, function(n) {
                        switch (n.label) {
                            case 0:
                                return n.trys.push([0, 2, , 3]), this.scheduleSendACK(), [4, this._handleServerEvents(e)];
                            case 1:
                                return n.sent(), this._postHandleServerEventsValidityCheck(e), [3, 3];
                            case 2:
                                throw t = n.sent(), Object(d.c)(ji, Pi.REALTIME_DB_HANDLE_EVENT_ERROR, !0), t;
                            case 3:
                                return [2]
                        }
                    })
                })
            }, e.prototype._handleServerEvents = function(e) {
                return Object(o.b)(this, void 0, void 0, function() {
                    var t, n, r, i, a, s, c, f, l, h, p = this;
                    return Object(o.d)(this, function(b) {
                        if (t = e.requestId, !(n = e.msgData.events).length || !this.sessionInfo) return [2];
                        r = this.sessionInfo;
                        try { i = n.map(Ki) } catch (e) { return this.closeWithError(new u.b({ errCode: _.a.SDK_DATABASE_REALTIME_LISTENER_RECEIVE_INVALID_SERVER_DATA, errMsg: e })), [2] }
                        for (a = Object(o.f)(r.currentDocs), s = !1, c = function(n, c) {
                                var l, h, b = i[n];
                                if (r.currentEventId >= b.id) return !i[n - 1] || b.id > i[n - 1].id ? Object(d.c)(ji, Pi.REALTIME_DB_RECV_DUPLICATE_EVENT, !0) : (console.error("[realtime listener] server non-fatal error: events out of order (the latter event's id is smaller than that of the former) (requestId " + t + ")"), Object(d.c)(ji, Pi.REALTIME_DB_RECV_DUPLICATE_EVENT_AND_EVENT_OUT_OF_ORDER, !0)), "continue";
                                if (r.currentEventId === b.id - 1) {
                                    switch (b.dataType) {
                                        case "update":
                                            if (!b.doc) switch (b.queueType) {
                                                case "update":
                                                case "dequeue":
                                                    if (T = a.find(function(e) { return e._id === b.docId })) {
                                                        var g = Ni(T);
                                                        if (b.updatedFields)
                                                            for (var E in b.updatedFields) In(g, E, b.updatedFields[E]);
                                                        if (b.removedFields) try {
                                                            for (var O = (l = void 0, Object(o.g)(b.removedFields)), y = O.next(); !y.done; y = O.next()) {
                                                                E = y.value;
                                                                Bn(g, E)
                                                            }
                                                        } catch (e) { l = { error: e } } finally { try { y && !y.done && (h = O.return) && h.call(O) } finally { if (l) throw l.error } }
                                                        b.doc = g
                                                    } else console.error("[realtime listener] internal non-fatal server error: unexpected update dataType event where no doc is associated."), Object(d.c)(ji, Pi.REALTIME_DB_UNEXPECTED_EVENT_DATATYPE_UPDATE_NO_ASSOCIATED_DOC, !0);
                                                    break;
                                                case "enqueue":
                                                    var m = new u.b({ errCode: _.a.SDK_DATABASE_REALTIME_LISTENER_UNEXPECTED_FATAL_ERROR, errMsg: 'HandleServerEvents: full doc is not provided with dataType="update" and queueType="enqueue" (requestId ' + e.requestId + ")" });
                                                    throw f.closeWithError(m), m
                                            }
                                            break;
                                        case "limit":
                                            if (!b.doc) switch (b.queueType) {
                                                case "dequeue":
                                                    var T;
                                                    (T = a.find(function(e) { return e._id === b.docId })) ? b.doc = T: console.error("[realtime listener] internal non-fatal server error: unexpected limit dataType dequeue queueType event where no doc is associated.")
                                            }
                                            break;
                                        case "replace":
                                            if (!b.doc) { m = new u.b({ errCode: _.a.SDK_DATABASE_REALTIME_LISTENER_UNEXPECTED_FATAL_ERROR, errMsg: 'HandleServerEvents: full doc is not provided with dataType="replace" (requestId ' + e.requestId + ")" }); throw f.closeWithError(m), m }
                                            break;
                                        case "remove":
                                            (g = a.find(function(e) { return e._id === b.docId })) ? b.doc = g: (console.error("[realtime listener] internal non-fatal server error: unexpected remove event where no doc is associated."), Object(d.c)(ji, Pi.REALTIME_DB_UNEXPECTED_EVENT_REMOVE_NO_ASSOCIATED_DOC, !0))
                                    }
                                    switch (b.queueType) {
                                        case "init":
                                            s ? a.push(b.doc) : (s = !0, a = [b.doc]);
                                            break;
                                        case "enqueue":
                                            a.push(b.doc);
                                            break;
                                        case "dequeue":
                                            (v = a.findIndex(function(e) { return e._id === b.docId })) > -1 ? a.splice(v, 1) : (console.error("[realtime listener] internal non-fatal server error: unexpected dequeue event where no doc is associated."), Object(d.c)(ji, Pi.REALTIME_DB_UNEXPECTED_EVENT_DEQUEUE_NO_ASSOCIATED_DOC, !0));
                                            break;
                                        case "update":
                                            var v;
                                            (v = a.findIndex(function(e) { return e._id === b.docId })) > -1 ? a[v] = b.doc : (console.error("[realtime listener] internal non-fatal server error: unexpected queueType update event where no doc is associated."), Object(d.c)(ji, Pi.REALTIME_DB_UNEXPECTED_EVENT_QUEUETYPE_UPDATE_NO_ASSOCIATED_DOC, !0))
                                    }
                                    if (n === c - 1 || i[n + 1] && i[n + 1].id !== b.id) {
                                        var S = Object(o.f)(a),
                                            N = i.slice(0, n + 1).filter(function(e) { return e.id === b.id });
                                        f.sessionInfo.currentEventId = b.id, f.sessionInfo.currentDocs = a, f.sessionInfo.currentEventTS = Date.now();
                                        var I = new Ui({ id: b.id, type: "init" === N[0].queueType ? "init" : void 0, docChanges: f.getEJSON().deserialize(N), docs: f.getEJSON().deserialize(S), EJSON: f.getEJSON(), requestId: t, watchId: f.watchId });
                                        Li.a.surroundThirdByTryCatch(function() { return p.listener.onChange(I) })(), f.debug && f._snapshotHistory.push(I)
                                    }
                                } else Object(d.c)(ji, Pi.REALTIME_DB_EVENT_OUT_OF_ORDER, !0), f._fsm.transition(Si.NEED_REBUILD_WATCH)
                            }, f = this, l = 0, h = i.length; l < h; l++) c(l, h);
                        return [2]
                    })
                })
            }, e.prototype._postHandleServerEventsValidityCheck = function(e) { this.sessionInfo ? (this.sessionInfo.expectEventId && this.sessionInfo.currentEventId >= this.sessionInfo.expectEventId && this.clearWaitExpectedEvent(), this.sessionInfo.currentEventId < e.msgData.currEvent && console.warn("[realtime listener] internal non-fatal error: client eventId " + this.sessionInfo.currentEventId + " does not match with server event id after server event handling " + e.msgData.currEvent + " (requestId " + e.requestId + ")")) : console.error("[realtime listener] internal non-fatal error: sessionInfo lost after server event handling, this should never occur. (requestId " + e.requestId + ")") }, e.prototype.clearWaitExpectedEvent = function() { this._waitExpectedTimeoutId && (clearTimeout(this._waitExpectedTimeoutId), this._waitExpectedTimeoutId = void 0) }, e.prototype.onMessage = function(e) {
                var t = this;
                switch (this._fsm.currentState) {
                    case vi.INIT_WATCH_SUCCESS:
                    case vi.REBUILD_WATCH_SUCCESS:
                        break;
                    case vi.PAUSED:
                        if ("ERROR" !== e.msgType) return;
                        break;
                    default:
                        return void console.warn("[realtime listener] internal non-fatal error: unexpected message received while state is " + this._fsm.currentState)
                }
                if (this.sessionInfo) switch (this.scheduleSendACK(), e.msgType) {
                    case "NEXT_EVENT":
                        0, this.handleServerEvents(e);
                        break;
                    case "CHECK_EVENT":
                        this.sessionInfo.currentEventId < e.msgData.currEvent && (this.sessionInfo.expectEventId = e.msgData.currEvent, this.clearWaitExpectedEvent(), this._waitExpectedTimeoutId = setTimeout(function() { t._fsm.transition(Si.NEED_REBUILD_WATCH) }, this.getWaitExpectedTimeoutLength()));
                        break;
                    case "ERROR":
                        this.closeWithError(new u.b({ errCode: _.a.SDK_DATABASE_REALTIME_LISTENER_SERVER_ERROR_MSG, errMsg: e.msgData.code + " - " + e.msgData.message }));
                        break;
                    default:
                        0
                } else console.warn("[realtime listener] internal non-fatal error: sessionInfo not found while message is received.")
            }, e.prototype.closeWithError = function(e, t) {
                var n = this;
                if (void 0 === t && (t = !0), this._fsm.currentState !== vi.CLOSED && this._fsm.transition(Si.CLOSE), !this.userOnErrorInvoked) {
                    var r = this._fsm.getHistoryRepresentation({ limit: 20 });
                    Object(u.e)(e) ? (e.errMsg += "\nhistory " + r, e.history = r) : e && ((e = new u.b({ errCode: _.a.SDK_DATABASE_REALTIME_LISTENER_UNEXPECTED_FATAL_ERROR, errMsg: e + " \nhistory " + r })).history = r), this.clearACKSchedule(), Li.a.surroundThirdByTryCatch(function() { return n.listener.onError(e) })(), this.userOnErrorInvoked = !0, this.onWatchClose(this, this.sessionInfo && this.sessionInfo.queryID || ""), t && this.sendCloseWatch().catch(Gi), this.sessionInfo = void 0
                }
            }, e
        }();

    function Ki(e) { var t = { id: e.ID, dataType: e.DataType, queueType: e.QueueType, docId: e.DocID, doc: e.Doc && "{}" !== e.Doc ? JSON.parse(e.Doc) : void 0 }; return "update" === e.DataType && (e.UpdatedFields && (t.updatedFields = JSON.parse(e.UpdatedFields)), (e.removedFields || e.RemovedFields) && (t.removedFields = e.removedFields ? JSON.parse(e.removedFields) : JSON.parse(e.RemovedFields))), t }
    var Vi, Xi = { 1000: { code: 1e3, name: "Normal Closure", description: "Normal closure; the connection successfully completed whatever purpose for which it was created." }, 1001: { code: 1001, name: "Going Away", description: "The endpoint is going away, either because of a server failure or because the browser is navigating away from the page that opened the connection." }, 1002: { code: 1002, name: "Protocol Error", description: "The endpoint is terminating the connection due to a protocol error." }, 1003: { code: 1003, name: "Unsupported Data", description: "The connection is being terminated because the endpoint received data of a type it cannot accept (for example, a text-only endpoint received binary data)." }, 1005: { code: 1005, name: "No Status Received", description: "Indicates that no status code was provided even though one was expected." }, 1006: { code: 1006, name: "Abnormal Closure", description: "Used to indicate that a connection was closed abnormally (that is, with no close frame being sent) when a status code is expected." }, 1007: { code: 1007, name: "Invalid frame payload data", description: "The endpoint is terminating the connection because a message was received that contained inconsistent data (e.g., non-UTF-8 data within a text message)." }, 1008: { code: 1008, name: "Policy Violation", description: "The endpoint is terminating the connection because it received a message that violates its policy. This is a generic status code, used when codes 1003 and 1009 are not suitable." }, 1009: { code: 1009, name: "Message too big", description: "The endpoint is terminating the connection because a data frame was received that is too large." }, 1010: { code: 1010, name: "Missing Extension", description: "The client is terminating the connection because it expected the server to negotiate one or more extension, but the server didn't." }, 1011: { code: 1011, name: "Internal Error", description: "The server is terminating the connection because it encountered an unexpected condition that prevented it from fulfilling the request." }, 1012: { code: 1012, name: "Service Restart", description: "The server is terminating the connection because it is restarting." }, 1013: { code: 1013, name: "Try Again Later", description: "The server is terminating the connection due to a temporary condition, e.g. it is overloaded and is casting off some of its clients." }, 1014: { code: 1014, name: "Bad Gateway", description: "The server was acting as a gateway or proxy and received an invalid response from the upstream server. This is similar to 502 HTTP Status Code." }, 1015: { code: 1015, name: "TLS Handshake", description: "Indicates that the connection was closed due to a failure to perform a TLS handshake (e.g., the server certificate can't be verified)." }, 3000: { code: 3e3, name: "Reconnect WebSocket", description: "The client is terminating the connection because it wants to reconnect" }, 3001: { code: 3001, name: "No Realtime Listeners", description: "The client is terminating the connection because no more realtime listeners exist" }, 3002: { code: 3002, name: "Heartbeat Ping Error", description: "The client is terminating the connection due to its failure in sending heartbeat messages" }, 3003: { code: 3003, name: "Heartbeat Pong Timeout Error", description: "The client is terminating the connection because no heartbeat response is received from the server" }, 3004: { code: 3004, name: "Client Reconnect on Server Upgrade", description: "The client is terminating the connection in response to server upgrade" }, 3050: { code: 3050, name: "Server Close Unauthenticated Idle Connection", description: "The server is terminating the connection because the connection is idle and not authenticated" }, 3051: { code: 3051, name: "Server Upgrade", description: "The server is terminating the connection because it is upgrading" }, 3052: { code: 3052, name: "Server Requires Authentication", description: "The server is terminating the connection because it has not received authentication message as the connection's first message" } };
    ! function(e) { e[e.NormalClosure = 1e3] = "NormalClosure", e[e.GoingAway = 1001] = "GoingAway", e[e.ProtocolError = 1002] = "ProtocolError", e[e.UnsupportedData = 1003] = "UnsupportedData", e[e.NoStatusReceived = 1005] = "NoStatusReceived", e[e.AbnormalClosure = 1006] = "AbnormalClosure", e[e.InvalidFramePayloadData = 1007] = "InvalidFramePayloadData", e[e.PolicyViolation = 1008] = "PolicyViolation", e[e.MessageTooBig = 1009] = "MessageTooBig", e[e.MissingExtension = 1010] = "MissingExtension", e[e.InternalError = 1011] = "InternalError", e[e.ServiceRestart = 1012] = "ServiceRestart", e[e.TryAgainLater = 1013] = "TryAgainLater", e[e.BadGateway = 1014] = "BadGateway", e[e.TLSHandshake = 1015] = "TLSHandshake", e[e.ReconnectWebSocket = 3e3] = "ReconnectWebSocket", e[e.NoRealtimeListeners = 3001] = "NoRealtimeListeners", e[e.HeartbeatPingError = 3002] = "HeartbeatPingError", e[e.HeartbeatPongTimeoutError = 3003] = "HeartbeatPongTimeoutError", e[e.ReconnectOnServerUpgrade = 3004] = "ReconnectOnServerUpgrade", e[e.UnauthenticatedIdleConnection = 3050] = "UnauthenticatedIdleConnection", e[e.ServerUpgrade = 3051] = "ServerUpgrade", e[e.AuthenticationRequired = 3052] = "AuthenticationRequired" }(Vi || (Vi = {}));
    var Ji, Qi = function(e, t) {
            var n = Xi[e],
                r = n ? n.name + ", code " + e + ", reason " + (t || n.description) : "code " + e;
            return new u.b({ errCode: _.a.SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_CLOSED, errMsg: r })
        },
        Zi = { CONNECTING: 0, OPEN: 1, CLOSING: 2, CLOSED: 3 },
        eo = 3,
        to = 5e3,
        no = 1e4,
        ro = 5e3,
        io = 100,
        oo = function() {
            function e(e) {
                var t = this;
                this._virtualWSClient = new Set, this._queryIdClientMap = new Map, this._watchIdClientMap = new Map, this._pingFailed = 0, this._pongMissed = 0, this._logins = new Map, this._signatures = new Map, this._wsResponseWait = new Map, this._rttObserved = [], this._closedWatches = new Set, this.initWebSocketConnection = function(e, r) {
                    return void 0 === r && (r = t._maxReconnect), Object(o.b)(t, void 0, void 0, function() {
                        var t, r, i, a, s, c, f, l, p, b = this;
                        return Object(o.d)(this, function(g) {
                            switch (g.label) {
                                case 0:
                                    if (this._EJSON || (t = function() { return Object(o.b)(this, void 0, void 0, function() { var e, t; return Object(o.d)(this, function(r) { return e = Date.now(), t = n(30), Object(d.b)({ apiName: "_realtime.importBSON", apiStartTime: e, apiEndTime: Date.now() }), [2, t.EJSON] }) }) }().then(function(e) { return b._EJSON = e })), this._fsm.currentState !== Et.DISCONNECTED) return [2];
                                    this._fsm.transition(Ot.CONNECTION_START), this._logins = new Map, this._wsResponseWait = new Map, r = !1, i = [], a = !1, !this._totalConnectionTimeoutId && this._totalConnectionTimeout && this._totalConnectionTimeout !== 1 / 0 && (s = this._totalConnectionTimeout, this._totalConnectionTimeoutId = setTimeout(function() {
                                        a = !0, b._totalConnectionTimeoutId = void 0;
                                        var e = new u.c("reconnect timeout (reach totalConnectionTimeout " + s + "s)", { subtype: "totalConnectionTimeout", retryable: !1 });
                                        Object(d.c)(ji, Pi.REALTIME_DB_WS_TOTAL_CONNECTION_TIMEOUT, !0), b._fsm.transition({ type: Ot.CONNECTION_FAIL, error: e })
                                    }, 1e3 * s)), c = function(n) {
                                        var s, u, c, l;
                                        return Object(o.d)(this, function(n) {
                                            switch (n.label) {
                                                case 0:
                                                    return n.trys.push([0, 11, , 17]), [4, Object(N.a)()];
                                                case 1:
                                                    return n.sent().isConnected ? [3, 5] : e ? [3, 2] : (f._fsm.transition({ type: Ot.CONNECTION_FAIL, error: new Error("network offline") }), [2, { value: void 0 }]);
                                                case 2:
                                                    return [4, Object(N.e)()];
                                                case 3:
                                                    return n.sent(), 0 === f._virtualWSClient.size ? (f.clearTotalReconnectTimeout(), [2, { value: void 0 }]) : Object(h.b)() ? [4, Object(N.f)(io)] : [3, 5];
                                                case 4:
                                                    n.sent(), n.label = 5;
                                                case 5:
                                                    return a ? [2, { value: void 0 }] : [4, f.getSignature(f._connectionEnvId)];
                                                case 6:
                                                    return s = n.sent(), a ? [2, { value: void 0 }] : (u = Date.now(), [4, new Promise(function(e, t) { b._ws = Object(y.a)(b._context.identifiers)._socketSkipCheckDomainFactory().connectSocket({ url: s.wsUrl, header: { "content-type": "application/json" }, perMessageDeflate: !0, success: e, fail: t }) })]);
                                                case 7:
                                                    return n.sent(), a ? [2, { value: void 0 }] : (Object(d.b)({ apiName: "_realtime.connectSocket", apiStartTime: u, apiEndTime: Date.now() }), [4, f.initWebSocketEvent()]);
                                                case 8:
                                                    return n.sent(), a ? [2, { value: void 0 }] : t ? [4, t] : [3, 10];
                                                case 9:
                                                    if (n.sent(), a) return [2, { value: void 0 }];
                                                    n.label = 10;
                                                case 10:
                                                    return r = !0, [2, "break"];
                                                case 11:
                                                    return c = n.sent(), i.unshift(c), c.errCode === _.a.TCB_PERMISSION_DENIED ? [2, "break"] : [4, Object(N.a)()];
                                                case 12:
                                                    return l = n.sent().isConnected, a ? [2, { value: void 0 }] : l ? [4, Object(N.f)(f._reconnectInterval)] : [3, 14];
                                                case 13:
                                                    if (n.sent(), a) return [2, { value: void 0 }];
                                                    n.label = 14;
                                                case 14:
                                                    return Object(h.b)() ? [4, Object(N.f)(0)] : [3, 16];
                                                case 15:
                                                    if (n.sent(), a) return [2, { value: void 0 }];
                                                    n.label = 16;
                                                case 16:
                                                    return [3, 17];
                                                case 17:
                                                    return [2]
                                            }
                                        })
                                    }, f = this, l = this._maxReconnect, g.label = 1;
                                case 1:
                                    return l >= 0 ? [5, c(l)] : [3, 4];
                                case 2:
                                    if ("object" == typeof(p = g.sent())) return [2, p.value];
                                    if ("break" === p) return [3, 4];
                                    g.label = 3;
                                case 3:
                                    return l--, [3, 1];
                                case 4:
                                    return r ? (this.clearTotalReconnectTimeout(), Object(d.c)(ji, e ? Pi.REALTIME_DB_RECONNECT_WS_SUCCESS : Pi.REALTIME_DB_INIT_WS_SUCCESS, !0), this._fsm.transition(Ot.CONNECTION_SUCCESS), [2]) : (this.clearTotalReconnectTimeout(), Object(d.c)(ji, e ? Pi.REALTIME_DB_RECONNECT_WS_FAIL : Pi.REALTIME_DB_INIT_WS_FAIL, !0), e ? this._fsm.transition({ type: Ot.CONNECTION_FAIL, error: new u.b({ errCode: _.a.SDK_DATABASE_REALTIME_LISTENER_RECONNECT_WS_FAIL, errMsg: "errors of each retry (latest to oldest): " + JSON.stringify(i.map(function(e) { return e + "" })) }) }) : this._fsm.transition({ type: Ot.CONNECTION_FAIL, error: new u.b({ errCode: _.a.SDK_DATABASE_REALTIME_LISTENER_INIT_WS_FAIL, errMsg: "errors of each retry (latest to oldest): " + JSON.stringify(i.map(function(e) { return e + "" })) }) }), [2])
                            }
                        })
                    })
                }, this.initWebSocketEvent = function() {
                    return new Promise(function(e, n) {
                        if (!t._ws) throw new Error("can not initWebSocketEvent, ws not exists");
                        var r = !1;
                        t._ws.onOpen(function(n) { t._context.debug && console.warn("[realtime] ws event: open", n), r = !0, e() });
                        var i = null;
                        t._ws.onError(function(e) { i = e, t._logins = new Map, r ? (t._context.debug && console.error("[realtime] ws event: error", e), t.clearHeartbeat(), Object(d.c)(ji, Pi.REALTIME_DB_WS_ONERROR_WHILE_ACTIVE, !0)) : (t._context.debug && console.error("[realtime] ws open failed with ws event: error", e), n(e), Object(d.c)(ji, Pi.REALTIME_DB_WS_ONERROR_BEFORE_OPEN, !0)) }), t._ws.onClose(function(e) {
                            t._logins = new Map, t.clearHeartbeat();
                            var n = i || Qi(e.code);
                            switch (e.code) {
                                case Vi.ReconnectOnServerUpgrade:
                                case Vi.ReconnectWebSocket:
                                case Vi.NoRealtimeListeners:
                                    t._fsm.transition({ type: Ot.DISCONNECT, error: n });
                                    break;
                                case Vi.HeartbeatPingError:
                                case Vi.HeartbeatPongTimeoutError:
                                case Vi.NormalClosure:
                                case Vi.AbnormalClosure:
                                    t._maxReconnect > 0 ? (t._fsm.transition({ type: Ot.DISCONNECT, error: n }), t.initWebSocketConnection(!0)) : t._fsm.transition({ type: Ot.CONNECTION_FAIL, error: n }), e.code === Vi.HeartbeatPingError ? Object(d.c)(ji, Pi.REALTIME_DB_WS_ONCLOSE_HEARTBEAT_PING_FAIL, !0) : e.code === Vi.HeartbeatPongTimeoutError ? Object(d.c)(ji, Pi.REALTIME_DB_WS_ONCLOSE_HEARTBEAT_PONG_TIMEOUT, !0) : Object(d.c)(ji, Pi.REALTIME_DB_WS_ONCLOSE_AB_NORMAL_CLOSURE, !0);
                                    break;
                                case Vi.UnauthenticatedIdleConnection:
                                    t._fsm.transition({ type: Ot.CONNECTION_FAIL, error: Qi(e.code, e.reason) }), Object(d.c)(ji, Pi.REALTIME_DB_WS_ONCLOSE_SERVER_CLOSE_NO_AUTH, !0);
                                    break;
                                case Vi.ServerUpgrade:
                                    t._fsm.transition({ type: Ot.DISCONNECT, error: n }), t.initWebSocketConnection(!0), Object(d.c)(ji, Pi.REALTIME_DB_WS_ONCLOSE_SERVER_CLOSE_FOR_UPGRADE, !0);
                                    break;
                                default:
                                    t._maxReconnect > 0 ? (t._fsm.transition({ type: Ot.DISCONNECT, error: n }), t.initWebSocketConnection(!0)) : t._fsm.transition({ type: Ot.CONNECTION_FAIL, error: Qi(e.code, e.reason) }), Object(d.c)(ji, Pi.REALTIME_DB_WS_ONCLOSE_UNKNOWN_ORIGIN, !0)
                            }
                            Object(d.c)(ji, Pi.REALTIME_DB_WS_ONCLOSE, !0)
                        });
                        var o = { timing: {}, startKey: "apiStartTime", endKey: "apiEndTime", samplePicker: d.d, autoReport: "_realtime.onSocketMessage" };
                        t._ws.onMessage(Object(d.e)(t.onSocketMessage, o)), t.heartbeat()
                    })
                }, this.isWSConnected = function() { return Boolean(t._ws && t._ws.readyState === Zi.OPEN) }, this.onSocketMessage = function(e) {
                    var n, r = e.data;
                    t.heartbeat();
                    try { n = JSON.parse(r) } catch (e) { throw new Error("[realtime] onMessage parse res.data error: " + e) }
                    t._context.debug && console.log("[realtime] onMessage " + n.msgType + " (" + (new Date).toLocaleString() + ")", n);
                    var i = t._wsResponseWait.get(n.requestId);
                    if (i) { try { "ERROR" === n.msgType ? i.reject(new xi(n)) : i.resolve(n) } catch (e) { t._context.debug && console.error("ws onMessage responseWaitSpec.resolve(msg) errored:", e) } finally { t._wsResponseWait.delete(n.requestId) } if (i.skipOnMessage) return }
                    if ("PONG" !== n.msgType) {
                        var o = n.watchId && t._watchIdClientMap.get(n.watchId);
                        if (o) o.onMessage(n);
                        else switch (n.watchId ? t._closedWatches.has(n.watchId) ? Object(d.c)(ji, Pi.REALTIME_DB_RECV_MSG_WITH_CLOSED_WATCHID, !0) : Object(d.c)(ji, Pi.REALTIME_DB_RECV_MSG_WITH_UNKNOWN_WATCHID, !0) : Object(d.c)(ji, Pi.REALTIME_DB_RECV_MSG_WITHOUT_WATCHID, !0), n.msgType) {
                            case "INIT_EVENT":
                            case "NEXT_EVENT":
                            case "CHECK_EVENT":
                                (o = t._queryIdClientMap.get(n.msgData.queryID)) && o.onMessage(n)
                        }
                    } else if (t._lastPingSendTS) {
                        var a = Date.now() - t._lastPingSendTS;
                        if (a > no) return void(t._context.debug && console.warn("[realtime] untrusted rtt observed: " + a));
                        t._rttObserved.length >= eo && t._rttObserved.splice(0, t._rttObserved.length - eo + 1), t._rttObserved.push(a)
                    }
                }, this.login = function(e, n, r) {
                    return Object(o.b)(t, void 0, void 0, function() {
                        var t, i, a, s, u, c, f, l, h = this;
                        return Object(o.d)(this, function(p) {
                            switch (p.label) {
                                case 0:
                                    if (e = e || this._context.env || this._defaultEnvId, !n)
                                        if (e) { if (t = this._logins.get(e)) { if (t.loggedIn && t.loginResult) return [2, t.loginResult]; if (t.loggingInPromise) return [2, t.loggingInPromise] } } else if ((i = this._logins.get("")) && i.loggingInPromise) return [2, i.loggingInPromise];
                                    0, a = new Promise(function(t, i) {
                                        return Object(o.b)(h, void 0, void 0, function() {
                                            var a, s, u, c, f;
                                            return Object(o.d)(this, function(o) {
                                                switch (o.label) {
                                                    case 0:
                                                        return o.trys.push([0, 3, , 4]), [4, r ? Object(d.e)(this.getSignature(e, n), { timing: r, startKey: "tunnelStartTime", endKey: "tunnelEndTime", condition: { emptyKey: !0 } }) : this.getSignature(e, n)];
                                                    case 1:
                                                        return a = o.sent(), s = Object(N.b)(), u = { watchId: void 0, requestId: Bi(), msgType: "LOGIN", msgData: { envId: a.envId, signStr: a.signStr, secretVersion: a.secretVersion, referrer: "mp", sdkVersion: s.version, dataVersion: s.updateDateInDashes } }, [4, this.send({ msg: u, waitResponse: !0, skipOnMessage: !0, timeout: ro })];
                                                    case 2:
                                                        return (c = o.sent()).msgData.code ? i(new Error(c.msgData.code + " " + c.msgData.message)) : t({ envId: a.envId }), [3, 4];
                                                    case 3:
                                                        return f = o.sent(), i(f), [3, 4];
                                                    case 4:
                                                        return [2]
                                                }
                                            })
                                        })
                                    }), s = e && this._logins.get(e), u = Date.now(), s ? (s.loggedIn = !1, s.loggingInPromise = a, s.loginStartTS = u) : (s = { loggedIn: !1, loggingInPromise: a, loginStartTS: u }, this._logins.set(e || "", s)), p.label = 1;
                                case 1:
                                    return p.trys.push([1, 3, , 4]), [4, a];
                                case 2:
                                    if (c = p.sent(), (f = this._logins.get(e || "")) && f === s && f.loginStartTS === u) return s.loggedIn = !0, s.loggingInPromise = void 0, s.loginStartTS = void 0, s.loginResult = c, [2, c];
                                    if (f) { if (f.loggedIn && f.loginResult) return [2, f.loginResult]; if (f.loggingInPromise) return [2, f.loggingInPromise]; throw new Error("ws unexpected login info") }
                                    throw new Error("ws login info reset");
                                case 3:
                                    throw l = p.sent(), s.loggedIn = !1, s.loggingInPromise = void 0, s.loginStartTS = void 0, s.loginResult = void 0, l;
                                case 4:
                                    return [2]
                            }
                        })
                    })
                }, this.getSignature = function(e, n) {
                    return Object(o.b)(t, void 0, void 0, function() {
                        var t, r, i, a;
                        return Object(o.d)(this, function(s) {
                            switch (s.label) {
                                case 0:
                                    if (e = e || this._context.env || this._defaultEnvId, !n && e && this._signatures.has(e)) { if (t = this._signatures.get(e), Date.now() < t.expireTS) return [2, t] } else 0;
                                    return r = Date.now() + 6e4, [4, function(e, t) {
                                        return Object(o.b)(this, void 0, void 0, function() {
                                            var n, r;
                                            return Object(o.d)(this, function(i) {
                                                switch (i.label) {
                                                    case 0:
                                                        return [4, e.request({ apiName: "tcbapi_db_get_realtime_connection", env: t || e.env, serviceName: e.name, serializedReqData: JSON.stringify({}), requireDataNotEmpty: !0 })];
                                                    case 1:
                                                        return n = i.sent(), [2, { envId: (r = n.data).env_id, secretVersion: r.secret_version, signStr: r.sign_str, wsUrl: r.ws_url }]
                                                }
                                            })
                                        })
                                    }(this._context, e)];
                                case 1:
                                    return i = s.sent(), Date.now() - r > 6e4 ? [2, this.getSignature(e, n)] : (a = Object(o.a)(Object(o.a)({}, i), { expireTS: r }), this._signatures.set(a.envId, a), e || (this._defaultEnvId = a.envId), [2, a])
                            }
                        })
                    })
                }, this.getWaitExpectedTimeoutLength = function() { return t._rttObserved.length ? t._rttObserved.reduce(function(e, t) { return e + t }) / t._rttObserved.length * 1.5 : to }, this.ping = function() {
                    return Object(o.b)(t, void 0, void 0, function() {
                        var e;
                        return Object(o.d)(this, function(t) {
                            switch (t.label) {
                                case 0:
                                    return e = { watchId: void 0, requestId: Bi(), msgType: "PING", msgData: null }, [4, this.send({ msg: e })];
                                case 1:
                                    return t.sent(), this._context.debug && console.log("ping sent"), [2]
                            }
                        })
                    })
                }, this.send = function(e) {
                    return new Promise(function(n, r) {
                        return Object(o.b)(t, void 0, void 0, function() {
                            var t, i, a, s, c, f = this;
                            return Object(o.d)(this, function(l) {
                                if (this._fsm.currentState !== Et.CONNECTED) return [2, r(new Error("websocket not connected"))];
                                i = !1, a = !1, s = function(e) { i = !0, t && clearTimeout(t), n(e) }, c = function(e) { a = !0, t && clearTimeout(t), r(e) }, e.timeout && (t = setTimeout(function() {
                                    return Object(o.b)(f, void 0, void 0, function() {
                                        return Object(o.d)(this, function(e) {
                                            switch (e.label) {
                                                case 0:
                                                    return i && a ? [3, 2] : [4, Object(N.f)(0)];
                                                case 1:
                                                    e.sent(), i && a || c(new u.c("wsclient.send timedout")), e.label = 2;
                                                case 2:
                                                    return [2]
                                            }
                                        })
                                    })
                                }, e.timeout));
                                try {
                                    if (this._context.debug && console.log("[realtime] ws send " + e.msg.msgType + " (" + (new Date).toLocaleString() + "): ", e), !this._ws) return c(new Error("invalid state: ws connection not exists, can not send message")), [2];
                                    if (this._ws.readyState !== Zi.OPEN) return c(new Error("ws readyState invalid: " + this._ws.readyState + ", can not send message")), [2];
                                    e.waitResponse && this._wsResponseWait.set(e.msg.requestId, { resolve: s, reject: c, skipOnMessage: e.skipOnMessage }), this._ws.send({ data: JSON.stringify(e.msg), success: function(t) { e.waitResponse || s(t) }, fail: function(t) { c(t), e.waitResponse && f._wsResponseWait.delete(e.msg.requestId) } })
                                } catch (e) { c(e) }
                                return [2]
                            })
                        })
                    })
                }, this.onWatchStart = function(e, n) { t._queryIdClientMap.set(n, e) }, this.onWatchClose = function(e, n) { n && t._queryIdClientMap.delete(n), t._watchIdClientMap.delete(e.watchId), t._virtualWSClient.delete(e), t._closedWatches.add(e.watchId), t._virtualWSClient.size || t.close(Vi.NoRealtimeListeners) }, this.getEJSON = function() { return t._EJSON }, this._fsm = new Ci({ initialState: Et.DISCONNECTED, states: Kt }), this._serviceContext = e.serviceContext
            }
            return Object.defineProperty(e.prototype, "_context", { get: function() { return this._serviceContext }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "_maxReconnect", { get: function() { return this._context.appConfig.realtimeMaxReconnect }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "_reconnectInterval", { get: function() { return this._context.appConfig.realtimeReconnectInterval }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "_totalConnectionTimeout", { get: function() { return this._context.appConfig.realtimeTotalConnectionTimeout }, enumerable: !1, configurable: !0 }), e.prototype.heartbeat = function(e) {
                var t = this;
                this.clearHeartbeat(), this._pingTimeoutId = setTimeout(function() {
                    return Object(o.b)(t, void 0, void 0, function() {
                        var e = this;
                        return Object(o.d)(this, function(t) {
                            switch (t.label) {
                                case 0:
                                    return t.trys.push([0, 2, , 3]), this._ws && this._ws.readyState === Zi.OPEN ? (this._lastPingSendTS = Date.now(), [4, this.ping()]) : [2];
                                case 1:
                                    return t.sent(), this._pingFailed = 0, this._pongTimeoutId = setTimeout(function() { e._context.debug && console.error("pong timed out"), e._pongMissed < 2 ? (e._pongMissed++, e.heartbeat(!0)) : e.close(Vi.HeartbeatPongTimeoutError) }, this._context.appConfig.realtimePongWaitTimeout), [3, 3];
                                case 2:
                                    return t.sent(), this._pingFailed < 2 ? (this._pingFailed++, this.heartbeat()) : this.close(Vi.HeartbeatPingError), [3, 3];
                                case 3:
                                    return [2]
                            }
                        })
                    })
                }, e ? 0 : this._context.appConfig.realtimePingInterval)
            }, e.prototype.clearHeartbeat = function() { this._pingTimeoutId && clearTimeout(this._pingTimeoutId), this._pongTimeoutId && clearTimeout(this._pongTimeoutId) }, e.prototype.clearTotalReconnectTimeout = function() { this._totalConnectionTimeoutId && clearTimeout(this._totalConnectionTimeoutId) }, e.prototype.close = function(e) { this.clearHeartbeat(), this._ws && (this._ws.close({ code: e, reason: Xi[e].name }), this._ws = void 0) }, e.prototype.watch = function(e) {
                var t = this,
                    n = { apiStartTime: Date.now() },
                    r = !1,
                    i = function() { Object(d.b)(Object(o.a)(Object(o.a)({}, n), { apiName: e.reportAPIName })) },
                    a = e.onChange,
                    s = e.onError;
                this._fsm.currentState === Et.DISCONNECTED && (this._connectionEnvId = e.envId, this.initWebSocketConnection(!1));
                var u = new Hi(Object(o.a)(Object(o.a)({}, e), { parentFSM: this._fsm, send: this.send, login: this.login, isWSConnected: this.isWSConnected, getWaitExpectedTimeoutLength: this.getWaitExpectedTimeoutLength, getEJSON: this.getEJSON, getServiceContext: function() { return t._context }, onWatchStart: this.onWatchStart, onWatchClose: this.onWatchClose, timing: n, debug: this._context.debug, wsclient: this, onChange: f, onError: l }));
                this._virtualWSClient.add(u), this._watchIdClientMap.set(u.watchId, u);
                var c = u.listener;
                return c;

                function f() {
                    for (var e = this, t = [], o = 0; o < arguments.length; o++) t[o] = arguments[o];
                    r || (r = !0, n.apiEndTime = Date.now(), i()), h(), Li.a.surroundThirdByTryCatch(function() { return c.onChange.apply(e, t) })()
                }

                function l() {
                    for (var e = this, t = [], o = 0; o < arguments.length; o++) t[o] = arguments[o];
                    r || (r = !0, n.apiEndTime = Date.now(), i()), h(), Li.a.surroundThirdByTryCatch(function() { return c.onError.apply(e, t) })()
                }

                function h() { c.onChange === f && (c.onChange = a), c.onError === l && (c.onError = s) }
            }, e
        }();
    ! function(e) { e.ASC = "asc", e.DESC = "desc" }(Ji || (Ji = {}));
    var ao = function(e) {
            var t = function() {
                    function t(t, n) {
                        var i = this;
                        if (this.watch = function(t) { return Object(s.d)(t, { onChange: "function", onError: "function" }), e.serviceContext.ws || (e.serviceContext.ws = new oo({ serviceContext: e.serviceContext })), e.serviceContext.ws.watch(Object(o.a)(Object(o.a)({}, t), { envId: e.database.config.env || e.serviceContext.env, collectionName: i.collectionName, query: JSON.stringify(e.engine.QuerySerializer.encode(i._query.where || {})), limit: i._query.limit, orderBy: i._query.order ? i._query.order.reduce(function(e, t) { return e[t.fieldPath] = t.order, e }, {}) : void 0, queryType: qe.WHERE, reportAPIName: "cloud.db.collection.watch" })) }, !t) throw new u.b({ errCode: _.a.SDK_API_PARAMETER_TYPE_ERROR, errMsg: "collectionName must be provided" });
                        this.collectionName = t, this._query = new r(n), Object.defineProperties(this, { _field: { enumerable: !1, configurable: !1, writable: !0 } }), this._field = n && n.field || {}
                    }
                    return t.prototype.field = function(e) { return Object(s.b)(e, "object", "field"), new t(this.collectionName, Object(o.a)(Object(o.a)({}, this._query.getProperties()), { field: e })) }, t.prototype.where = function(e) { return Object(s.b)(e, "condition", "where"), this._query.where ? new t(this.collectionName, Object(o.a)(Object(o.a)({}, this._query.getProperties()), { where: nt.and(this._query.where, e) })) : new t(this.collectionName, Object(o.a)(Object(o.a)({}, this._query.getProperties()), { where: e })) }, t.prototype.orderBy = function(e, n) { return Object(s.b)(e, "fieldPath", "orderBy"), Object(s.b)(n, "order", "orderBy"), new t(this.collectionName, Object(o.a)(Object(o.a)({}, this._query.getProperties()), { order: Object(o.f)(this._query.order || [], [{ fieldPath: e, order: n }]) })) }, t.prototype.limit = function(e) { return Object(s.b)(e, "max", "limit"), new t(this.collectionName, Object(o.a)(Object(o.a)({}, this._query.getProperties()), { limit: e })) }, t.prototype.skip = function(e) { return Object(s.b)(e, "offset", "skip"), new t(this.collectionName, Object(o.a)(Object(o.a)({}, this._query.getProperties()), { offset: e })) }, t.prototype.get = function(t) {
                        var n = this,
                            r = "collection.get",
                            i = { apiStartTime: +new Date };
                        var s = Object(a.a)(t),
                            c = new Promise(function(a, s) {
                                return Object(o.b)(n, void 0, void 0, function() {
                                    var c, f;
                                    return Object(o.d)(this, function(l) {
                                        switch (l.label) {
                                            case 0:
                                                return l.trys.push([0, 2, 3, 4]), [4, He({ env: e.database.config.env, collectionName: n.collectionName, query: e.engine.QuerySerializer.encode(n._query.where || {}), queryType: qe.WHERE, options: Gt(n, e), instanceContext: e, timing: i, explain: null === t || void 0 === t ? void 0 : t.explain })];
                                            case 1:
                                                return c = l.sent(), (null === t || void 0 === t ? void 0 : t.explain) && Object(h.b)() ? (a(c), [2]) : (a({ data: c.list, errMsg: Object(p.b)(r) }), [3, 4]);
                                            case 2:
                                                return f = l.sent(), s(Object(u.g)(f, r)), [3, 4];
                                            case 3:
                                                return Object(d.b)(Object(o.a)(Object(o.a)({}, i), { apiEndTime: +new Date, apiName: "cloud.db." + r })), [7];
                                            case 4:
                                                return [2]
                                        }
                                    })
                                })
                            });
                        if (!s) return c;
                        c.then(function(e) { Object(a.c)(r, t, e) }).catch(function(e) { Object(a.b)(r, t, e) })
                    }, t.prototype.update = function(t) {
                        var n = this,
                            r = "collection.update",
                            i = { apiStartTime: +new Date };
                        var c = Object(a.a)(t),
                            f = new Promise(function(a, c) {
                                return Object(o.b)(n, void 0, void 0, function() {
                                    var f, l;
                                    return Object(o.d)(this, function(_) {
                                        switch (_.label) {
                                            case 0:
                                                return _.trys.push([0, 2, 3, 4]),
                                                    function() { if (Object(s.b)(t, "options", "update"), Object(s.d)(t, { data: "object" }), !n._query.where) throw new u.b({ errCode: -1, errMsg: "query condition must be provided" }) }(), [4, Ke({ env: e.database.config.env, collectionName: n.collectionName, query: e.engine.QuerySerializer.encode(n._query.where || {}), data: e.engine.UpdateSerializer.encode(t.data), queryType: qe.WHERE, options: { multi: !1 !== t.multi, merge: !0 }, instanceContext: e, timing: i, explain: t.explain })];
                                            case 1:
                                                return f = _.sent(), (null === t || void 0 === t ? void 0 : t.explain) && Object(h.b)() ? [2, a(f)] : (a({ stats: { updated: f.updated }, errMsg: Object(p.b)(r) }), [3, 4]);
                                            case 2:
                                                return l = _.sent(), c(Object(u.g)(l, r)), [3, 4];
                                            case 3:
                                                return Object(d.b)(Object(o.a)(Object(o.a)({}, i), { apiEndTime: +new Date, apiName: "cloud.db." + r })), [7];
                                            case 4:
                                                return [2]
                                        }
                                    })
                                })
                            });
                        if (!c) return f;
                        f.then(function(e) { Object(a.c)(r, t, e) }).catch(function(e) { Object(a.b)(r, t, e) })
                    }, t.prototype.remove = function(t) {
                        var n = this,
                            r = "collection.remove",
                            i = { apiStartTime: +new Date };
                        var s = Object(a.a)(t),
                            c = new Promise(function(a, s) {
                                return Object(o.b)(n, void 0, void 0, function() {
                                    var c, f;
                                    return Object(o.d)(this, function(l) {
                                        switch (l.label) {
                                            case 0:
                                                return l.trys.push([0, 2, 3, 4]),
                                                    function() { if (!n._query.where || 0 === Object.keys(n._query.where).length) throw new u.b({ errCode: -1, errMsg: "query condition must be provided and not be empty" }) }(), [4, Ge({ env: e.database.config.env, collectionName: n.collectionName, query: e.engine.QuerySerializer.encode(n._query.where || {}), queryType: qe.WHERE, options: { multi: !0 }, instanceContext: e, timing: i, explain: null === t || void 0 === t ? void 0 : t.explain })];
                                            case 1:
                                                return c = l.sent(), (null === t || void 0 === t ? void 0 : t.explain) && Object(h.b)() ? [2, a(c)] : (a({ stats: { removed: c.removed || 0 }, errMsg: Object(p.b)(r) }), [3, 4]);
                                            case 2:
                                                return f = l.sent(), s(Object(u.g)(f, r)), [3, 4];
                                            case 3:
                                                return Object(d.b)(Object(o.a)(Object(o.a)({}, i), { apiEndTime: +new Date, apiName: "cloud.db." + r })), [7];
                                            case 4:
                                                return [2]
                                        }
                                    })
                                })
                            });
                        if (!s) return c;
                        c.then(function(e) { Object(a.c)(r, t, e) }).catch(function(e) { Object(a.b)(r, t, e) })
                    }, t.prototype.count = function(t) {
                        var r = this,
                            i = "collection.count",
                            s = { apiStartTime: +new Date },
                            c = function() {
                                return function(e) {
                                    return Object(o.b)(this, void 0, void 0, function() {
                                        var t, r, i, a, s, u, c, f, l, d;
                                        return Object(o.d)(this, function(o) {
                                            switch (o.label) {
                                                case 0:
                                                    return t = e.env, r = e.collectionName, i = e.query, a = e.instanceContext, s = e.timing, u = Object(h.b)() ? e.explain : void 0, c = { collection_name: r, query: JSON.stringify(i), query_type: qe.WHERE, explain: u }, f = JSON.stringify(c), s.tunnelStartTime = +new Date, [4, a.serviceContext.request({ apiName: "tcbapi_db_countdocument", serviceName: a.serviceContext.name, serializedReqData: f, requireDataNotEmpty: !0, env: t || a.serviceContext.env })];
                                                case 1:
                                                    return l = o.sent(), s.tunnelEndTime = +new Date, u ? [2, n(30).EJSON.deserialize(l.data)] : (d = l.data, s.tunnelTimeNoCSNetCost = d.baseresponse.stat.qbase_cost_time, [2, { total: d.total }])
                                            }
                                        })
                                    })
                                }({ env: e.database.config.env, collectionName: r.collectionName, query: e.engine.QuerySerializer.encode(r._query.where || {}), queryType: qe.WHERE, instanceContext: e, timing: s, explain: null === t || void 0 === t ? void 0 : t.explain })
                            };
                        var f = Object(a.a)(t),
                            l = new Promise(function(e, n) {
                                return Object(o.b)(r, void 0, void 0, function() {
                                    var r, a;
                                    return Object(o.d)(this, function(f) {
                                        switch (f.label) {
                                            case 0:
                                                return f.trys.push([0, 2, 3, 4]), [4, c()];
                                            case 1:
                                                return r = f.sent(), (null === t || void 0 === t ? void 0 : t.explain) && Object(h.b)() ? [2, e(r)] : (e({ total: r.total, errMsg: Object(p.b)(i) }), [3, 4]);
                                            case 2:
                                                return a = f.sent(), n(Object(u.g)(a, i)), [3, 4];
                                            case 3:
                                                return Object(d.b)(Object(o.a)(Object(o.a)({}, s), { apiEndTime: +new Date, apiName: "cloud.db." + i })), [7];
                                            case 4:
                                                return [2]
                                        }
                                    })
                                })
                            });
                        if (!f) return l;
                        l.then(function(e) { Object(a.c)(i, t, e) }).catch(function(e) { Object(a.b)(i, t, e) })
                    }, t.prototype.toJSON = function() {}, t
                }(),
                r = function() {
                    function e(e) { this.where = e && e.where, this.offset = e && e.offset, this.limit = e && e.limit, this.order = e && e.order, this.field = e && e.field }
                    return e.prototype.getProperties = function() { return { where: this.where, offset: this.offset, limit: this.limit, order: this.order, field: this.field } }, e
                }();
            return t
        },
        so = function(e) {
            return function() {
                function t(t, n) {
                    var r = this;
                    if (this.watch = function(t) { return Object(s.d)(t, { onChange: "function", onError: "function" }), e.serviceContext.ws || (e.serviceContext.ws = new oo({ serviceContext: e.serviceContext })), e.serviceContext.ws.watch(Object(o.a)(Object(o.a)({}, t), { envId: e.database.config.env || e.serviceContext.env, collectionName: r.collection.collectionName, query: JSON.stringify({ _id: r._id }), queryType: qe.DOC, reportAPIName: "cloud.db.document.watch" })) }, this.collection = t, this._id = n, null === n || void 0 === n) throw new u.b({ errCode: _.a.SDK_API_PARAMETER_TYPE_ERROR, errMsg: "docId must not be null or undefined" });
                    Object.defineProperties(this, { _field: { enumerable: !1, configurable: !1, writable: !0 } }), this._field = {}
                }
                return t.prototype.field = function(e) { return Object(s.b)(e, "object", "field"), Object(s.d)(e, "object", "field"), this._field = e, this }, t.prototype.get = function(t) {
                    var n = this,
                        r = { apiStartTime: +new Date };
                    var i = Object(a.a)(t),
                        s = new Promise(function(t, i) {
                            return Object(o.b)(n, void 0, void 0, function() {
                                var a, s, c;
                                return Object(o.d)(this, function(f) {
                                    switch (f.label) {
                                        case 0:
                                            return f.trys.push([0, 2, 3, 4]), a = this._id, [4, He({ env: e.database.config.env, collectionName: n.collection.collectionName, query: e.engine.QuerySerializer.encode({ _id: n._id }), options: { projection: e.engine.ProjectionSerializer.encode(n._field) }, queryType: qe.DOC, instanceContext: e, timing: r })];
                                        case 1:
                                            if (!(s = f.sent()).list || !s.list.length) throw new Error("cannot find document with _id " + a + ", please make sure that the document exists and you have the corresponding access permission");
                                            return t({ data: s.list[0], errMsg: Object(p.b)("document.get") }), [3, 4];
                                        case 2:
                                            return c = f.sent(), i(Object(u.g)(c, "document.get")), [3, 4];
                                        case 3:
                                            return Object(d.b)(Object(o.a)(Object(o.a)({}, r), { apiEndTime: +new Date, apiName: "cloud.db.document.get" })), [7];
                                        case 4:
                                            return [2]
                                    }
                                })
                            })
                        });
                    if (!i) return s;
                    s.then(function(e) { Object(a.c)("document.get", t, e) }).catch(function(e) { Object(a.b)("document.get", t, e) })
                }, t.prototype.set = function(t) {
                    var n = this,
                        r = { apiStartTime: +new Date },
                        i = function() {
                            return function(e) {
                                return Object(o.b)(this, void 0, void 0, function() {
                                    var t, n, r, i, a, u, c, l, d, h, p, _;
                                    return Object(o.d)(this, function(o) {
                                        switch (o.label) {
                                            case 0:
                                                return t = e.env, n = e.collectionName, r = e._id, i = e.data, e.options, a = e.instanceContext, u = e.timing, c = JSON.stringify(i), Object(s.c)({ input: c, max: a.serviceContext.appConfig.docSizeLimit, name: "record", maxWording: (a.serviceContext.appConfig.docSizeLimit / 1024).toFixed(0) + " KB" }), l = Object(f.f)(r), d = { collection_name: n, _id_type: l ? ze.NUMBER : ze.STRING, data: c }, l ? d._id_number = r : d._id = r, h = JSON.stringify(d), u.tunnelStartTime = +new Date, [4, a.serviceContext.request({ apiName: "tcbapi_db_setdocument", serviceName: a.serviceContext.name, serializedReqData: h, requireDataNotEmpty: !0, env: t || a.serviceContext.env })];
                                            case 1:
                                                return p = o.sent(), u.tunnelEndTime = +new Date, _ = p.data, u.tunnelTimeNoCSNetCost = _.baseresponse.stat.qbase_cost_time, [2, { _id: _._id_type === ze.NUMBER ? _._id_number : _._id, updated: _._id ? 0 : 1, created: _._id ? 1 : 0 }]
                                        }
                                    })
                                })
                            }({ env: e.database.config.env, collectionName: n.collection.collectionName, _id: n._id, data: e.engine.encodeInternalDataType(t.data), options: {}, instanceContext: e, timing: r })
                        };
                    var c = Object(a.a)(t),
                        l = new Promise(function(e, a) {
                            return Object(o.b)(n, void 0, void 0, function() {
                                var n, c;
                                return Object(o.d)(this, function(f) {
                                    switch (f.label) {
                                        case 0:
                                            return f.trys.push([0, 2, 3, 4]), Object(s.d)(t, { data: "object" }), Object(s.a)({ name: "options.data", target: t.data }), [4, i()];
                                        case 1:
                                            return n = f.sent(), e({ _id: n._id, errMsg: Object(p.b)("document.set"), stats: { updated: n.updated, created: n.created } }), [3, 4];
                                        case 2:
                                            return c = f.sent(), a(Object(u.g)(c, "document.set")), [3, 4];
                                        case 3:
                                            return Object(d.b)(Object(o.a)(Object(o.a)({}, r), { apiEndTime: +new Date, apiName: "cloud.db.document.set" })), [7];
                                        case 4:
                                            return [2]
                                    }
                                })
                            })
                        });
                    if (!c) return l;
                    l.then(function(e) { Object(a.c)("document.set", t, e) }).catch(function(e) { Object(a.b)("document.set", t, e) })
                }, t.prototype.update = function(t) {
                    var n = this,
                        r = { apiStartTime: +new Date };
                    var i = Object(a.a)(t),
                        c = new Promise(function(i, a) {
                            return Object(o.b)(n, void 0, void 0, function() {
                                var c, f;
                                return Object(o.d)(this, function(l) {
                                    switch (l.label) {
                                        case 0:
                                            return l.trys.push([0, 2, 3, 4]), Object(s.d)(t, { data: "object" }), Object(s.a)({ name: "options.data", target: t.data }), [4, Ke({ env: e.database.config.env, collectionName: n.collection.collectionName, query: e.engine.QuerySerializer.encode({ _id: n._id }), data: e.engine.UpdateSerializer.encode(t.data), queryType: qe.DOC, options: { multi: !1, merge: !1 }, instanceContext: e, timing: r })];
                                        case 1:
                                            return c = l.sent(), i({ stats: { updated: c.updated }, errMsg: Object(p.b)("document.update") }), [3, 4];
                                        case 2:
                                            return f = l.sent(), a(Object(u.g)(f, "document.update")), [3, 4];
                                        case 3:
                                            return Object(d.b)(Object(o.a)(Object(o.a)({}, r), { apiEndTime: +new Date, apiName: "cloud.db.document.update" })), [7];
                                        case 4:
                                            return [2]
                                    }
                                })
                            })
                        });
                    if (!i) return c;
                    c.then(function(e) { Object(a.c)("document.update", t, e) }).catch(function(e) { Object(a.b)("document.update", t, e) })
                }, t.prototype.remove = function(t) {
                    var n = this,
                        r = { apiStartTime: +new Date };
                    var i = Object(a.a)(t),
                        s = new Promise(function(t, i) {
                            return Object(o.b)(n, void 0, void 0, function() {
                                var a, s, c;
                                return Object(o.d)(this, function(f) {
                                    switch (f.label) {
                                        case 0:
                                            return f.trys.push([0, 2, 3, 4]), a = this._id, [4, Ge({ env: e.database.config.env, collectionName: n.collection.collectionName, query: e.engine.QuerySerializer.encode({ _id: n._id }), queryType: qe.DOC, options: {}, instanceContext: e, timing: r })];
                                        case 1:
                                            if (0 === (s = f.sent()).removed) throw new Error("cannot remove document with _id " + a + ", please make sure that the document exists and you have the corresponding Write permission");
                                            return t({ stats: { removed: s.removed || 0 }, errMsg: Object(p.b)("document.remove") }), [3, 4];
                                        case 2:
                                            return c = f.sent(), i(Object(u.g)(c, "document.remove")), [3, 4];
                                        case 3:
                                            return Object(d.b)(Object(o.a)(Object(o.a)({}, r), { apiEndTime: +new Date, apiName: "cloud.db.document.remove" })), [7];
                                        case 4:
                                            return [2]
                                    }
                                })
                            })
                        });
                    if (!i) return s;
                    s.then(function(e) { Object(a.c)("document.remove", t, e) }).catch(function(e) { Object(a.b)("document.remove", t, e) })
                }, t.prototype.toJSON = function() {}, t
            }()
        },
        uo = function(e) {
            var t = ao(e),
                n = so(e),
                r = Ve(e);
            return function(t) {
                function i(e) { var n = t.call(this, e) || this; return n.collectionName = e, n }
                return Object(o.c)(i, t), i.prototype.doc = function(e) { if (null === e || void 0 === e) throw Object(u.g)({ errCode: -1, errMsg: "docId must not be empty" }, "collection.doc"); return new n(this, e) }, i.prototype.add = function(t) {
                    var n = this,
                        r = "collection.add",
                        i = { apiStartTime: +new Date },
                        c = function() {
                            return function(e) {
                                return Object(o.b)(this, void 0, void 0, function() {
                                    var t, n, r, i, a, u, c, f, l, d;
                                    return Object(o.d)(this, function(o) {
                                        switch (o.label) {
                                            case 0:
                                                return t = e.env, n = e.collectionName, r = e.data, i = e.instanceContext, a = e.timing, u = JSON.stringify(r), Object(s.c)({ input: u, max: i.serviceContext.appConfig.docSizeLimit, name: "record", maxWording: (i.serviceContext.appConfig.docSizeLimit / 1024).toFixed(0) + " KB" }), c = { collection_name: n, data: u }, f = JSON.stringify(c), a.tunnelStartTime = +new Date, [4, i.serviceContext.request({ apiName: "tcbapi_db_adddocument", serviceName: i.serviceContext.name, serializedReqData: f, requireDataNotEmpty: !0, env: t || i.serviceContext.env })];
                                            case 1:
                                                return l = o.sent(), a.tunnelEndTime = +new Date, d = l.data, a.tunnelTimeNoCSNetCost = d.baseresponse.stat.qbase_cost_time, [2, { _id: d._id_type === ze.NUMBER ? d._id_number : d._id }]
                                        }
                                    })
                                })
                            }({ env: e.database.config.env, collectionName: n.collectionName, data: e.engine.encodeInternalDataType(t.data), instanceContext: e, timing: i })
                        };
                    var f = Object(a.a)(t),
                        l = new Promise(function(e, a) {
                            return Object(o.b)(n, void 0, void 0, function() {
                                var n, f;
                                return Object(o.d)(this, function(l) {
                                    switch (l.label) {
                                        case 0:
                                            return l.trys.push([0, 2, 3, 4]), Object(s.d)(t, { data: "object" }), [4, c()];
                                        case 1:
                                            return n = l.sent(), e({ _id: n._id, errMsg: Object(p.b)(r) }), [3, 4];
                                        case 2:
                                            return f = l.sent(), a(Object(u.g)(f, r)), [3, 4];
                                        case 3:
                                            return Object(d.b)(Object(o.a)(Object(o.a)({}, i), { apiEndTime: +new Date, apiName: "cloud.db." + r })), [7];
                                        case 4:
                                            return [2]
                                    }
                                })
                            })
                        });
                    if (!f) return l;
                    l.then(function(e) { Object(a.c)(r, t, e) }).catch(function(e) { Object(a.b)(r, t, e) })
                }, i.prototype.aggregate = function() { return new r(this, []) }, i
            }(t)
        },
        co = function(e) { return new fo(e) },
        fo = function() {
            function e(e) { Object(s.d)(e, { regexp: "string" }, "RegExp options"), e.options && Object(s.d)(e.options, "string"), this.regexp = e.regexp, this.options = e.options || "" }
            return Object.defineProperty(e.prototype, "_internalType", { get: function() { return Se }, enumerable: !1, configurable: !0 }), e.prototype.toJSON = function() { return { $regex: this.regexp, $options: this.options } }, e
        }(),
        lo = {},
        ho = {};
    for (var po in Re) lo[Re[po]] = "$" + Re[po];
    for (var po in se) lo[se[po]] = "$" + se[po];
    for (var po in je) lo[je[po]] = "$" + je[po];
    for (var po in Ue) ho[Ue[po]] = "$" + Ue[po];

    function _o(e) { return lo[e] || "$" + e.toLowerCase() }

    function bo(e) { return ho[e] || "$" + e.toLowerCase() }
    lo[Re.NEQ] = "$ne", lo[je.REMOVE] = "$unset", lo[je.SHIFT] = "$pop", lo[je.UNSHIFT] = "$push", lo[Re.GEO_NEAR] = "$nearSphere", lo[Re.GEO_WITHIN] = "$geoWithin", lo[Re.GEO_INTERSECTS] = "$geoIntersects";
    var go, Eo = function() {
            function e() {}
            return e.encodeStages = function(e) { return (new Oo).encodeStages(e) }, e.encode = function(e) { return (new Oo).encodeAny(e) }, e
        }(),
        Oo = function() {
            function e() {}
            return e.prototype.encodeStages = function(e) { var t = this; return e.map(function(e) { return t.encodePipelineStage(e) }) }, e.prototype.encodeAny = function(e) { var t = this; return qt(e) ? Ze(e) ? this.encodePipeline(e) : et(e) ? this.encodePipelineStage(e) : $e(e) ? this.encodeAggregateCommand(e) : zt(e) : Object(f.g)(e) ? this.encodeObject(e) : Object(f.b)(e) ? e.map(function(e) { return t.encodeAny(e) }) : e }, e.prototype.encodeObject = function(e) { var t = {}; for (var n in e) t[n] = this.encodeAny(e[n]); return t }, e.prototype.encodePipeline = function(e) { var t = this; return e._stages.map(function(e) { return t.encodeAny(e) }) }, e.prototype.encodePipelineStage = function(e) {
                var t, n, r = "$" + e.stage;
                switch (e.stage) {
                    case "match":
                        return (t = {})[r] = yo.encode(e.val), t;
                    default:
                        return (n = {})[r] = this.encodeAny(e.val), n
                }
            }, e.prototype.encodeAggregateCommand = function(e) { var t; return (t = {})[bo(e.operator)] = this.encodeAny(e.operands[0]), t }, e
        }(),
        yo = function() {
            function e() {}
            return e.encode = function(e) { return mo(e) }, e
        }(),
        mo = function(e) { return we(e) ? vo(e) : Le(e) ? So(e) : Ze(e) || $e(e) || et(e) ? Eo.encode(e) : Object(f.g)(e) ? To(e) : zt(e) },
        To = function(e) {
            var t, n = kt(e),
                r = [],
                i = ((t = {})[se.OR] = 0, t[se.NOR] = 0, t[se.AND] = 0, t[se.NOT] = 0, t),
                o = function(e) {
                    var t, o, a, s, u, c = n[e];
                    if (we(c)) switch (c.operator) {
                        case se.OR:
                        case se.NOR:
                        case se.AND:
                            i[c.operator]++, r.push(((t = {})[_o(c.operator)] = c.operands.map(function(t) { var n; return mo(((n = {})[e] = t, n)) }), t));
                            break;
                        case se.NOT:
                            var f = c.operands[0];
                            if (we(f)) switch (f.operator) {
                                case se.AND:
                                    i[se.OR]++, r.push(vo(new Ae(se.OR, f.operands.map(function(t) { var n; return (n = {})[e] = new Ae(se.NOT, [t]), n }))));
                                    break;
                                case se.OR:
                                    i[se.NOR]++, r.push(vo(new Ae(se.NOR, f.operands.map(function(t) { var n; return (n = {})[e] = t, n }))));
                                    break;
                                case se.NOR:
                                    i[se.OR]++, r.push(vo(new Ae(se.OR, f.operands.map(function(t) { var n; return (n = {})[e] = t, n }))));
                                    break;
                                case se.NOT:
                                    r.push(mo(((o = {})[e] = f.operands[0], o)))
                            } else r.push(((a = {})[e] = vo(c), a))
                    } else Le(c) ? r.push(((s = {})[e] = So(c), s)) : r.push(((u = {})[e] = zt(c), u))
                };
            for (var a in n) o(a);
            return No(r)
        },
        vo = function(e) {
            var t, n, r, i, a, s;
            switch (e.operator) {
                case se.AND:
                    if (e.operands.every(function(e) { return Le(e) })) {
                        var u = {};
                        try {
                            for (var c = Object(o.g)(e.operands), f = c.next(); !f.done; f = c.next()) {
                                var l = f.value;
                                Object.assign(u, So(l))
                            }
                        } catch (e) { t = { error: e } } finally { try { f && !f.done && (n = c.return) && n.call(c) } finally { if (t) throw t.error } }
                        return u
                    }
                    var d = _o(e.operator),
                        h = e.operands.map(mo);
                    return (r = {})[d] = h, r;
                case se.OR:
                case se.NOR:
                    d = _o(e.operator), h = e.operands.map(mo);
                    return (i = {})[d] = h, i;
                case se.NOT:
                    d = _o(e.operator), l = e.operands[0];
                    return (a = {})[d] = mo(l), a;
                default:
                    d = _o(e.operator), h = e.operands.map(mo);
                    return (s = {})[d] = h, s
            }
        },
        So = function(e) {
            var t, n, r, i, o, a, s, u, c = _o(e.operator);
            switch (e.operator) {
                case Re.EQ:
                case Re.NEQ:
                case Re.LT:
                case Re.LTE:
                case Re.GT:
                case Re.GTE:
                case Re.EXISTS:
                case Re.SIZE:
                    return (t = {})[c] = zt(e.operands[0]), t;
                case Re.IN:
                case Re.NIN:
                case Re.MOD:
                    return (n = {})[c] = zt(e.operands), n;
                case Re.ALL:
                    return (r = {})[c] = e.operands.map(mo), r;
                case Re.ELEM_MATCH:
                case Re.EXPR:
                    return (i = {})[c] = mo(e.operands[0]), i;
                case Re.GEO_NEAR:
                    return (o = {})[c] = { $geometry: zt(e.operands[0].geometry), $maxDistance: e.operands[0].maxDistance, $minDistance: e.operands[0].minDistance }, o;
                case Re.GEO_WITHIN:
                    var f = {};
                    return e.operands[0].geometry && (f.$geometry = zt(e.operands[0].geometry)), e.operands[0].centerSphere && (f.$centerSphere = zt(e.operands[0].centerSphere)), (a = {})[c] = f, a;
                case Re.GEO_INTERSECTS:
                    return (s = {})[c] = { $geometry: zt(e.operands[0].geometry) }, s;
                default:
                    return (u = {})[c] = e.operands.length > 1 ? e.operands.map(mo) : mo(e.operands[0]), u
            }
        },
        No = function(e) {
            var t, n, r, i, a = { $and: 0, $or: 0, $nor: 0 };
            try {
                for (var s = Object(o.g)(e), u = s.next(); !u.done; u = s.next()) {
                    (p = u.value).$and && a.$and++, p.$or && a.$or++, p.$nor && a.$nor++
                }
            } catch (e) { t = { error: e } } finally { try { u && !u.done && (n = s.return) && n.call(s) } finally { if (t) throw t.error } }
            var c = a.$and > 1 || a.$or > 1 || a.$nor > 1,
                f = !1,
                l = {};
            try {
                for (var d = Object(o.g)(e), h = d.next(); !h.done; h = d.next()) {
                    var p = h.value;
                    for (var _ in p) {
                        var b = p[_];
                        c ? f ? l.$and.push(p) : "$and" === _ || "$or" === _ || "$nor" === _ ? (f = !0, l.$and = [p]) : l[_] = b : l[_] = b
                    }
                }
            } catch (e) { r = { error: e } } finally { try { h && !h.done && (i = d.return) && i.call(d) } finally { if (r) throw r.error } }
            return l
        },
        Io = function() {
            function e() {}
            return e.encode = function(e) { return Ao(e) }, e
        }(),
        Ao = function(e) { return wo(e) },
        wo = function(e) {
            var t = kt(e),
                n = {};
            for (var r in t) {
                var i = t[r];
                if (Me(i)) {
                    var o = _o(i.operator);
                    switch (n[o] || (n[o] = {}), i.operator) {
                        case je.SET:
                        case je.INC:
                        case je.MUL:
                        case je.MIN:
                        case je.MAX:
                        case je.RENAME:
                        case je.BIT:
                            n[o][r] = zt(i.operands[0]);
                            break;
                        case je.REMOVE:
                            n[o][r] = "";
                            break;
                        case je.PUSH:
                            var a = void 0;
                            a = 1 === i.operands.length && Object(f.g)(i.operands[0]) ? { $each: i.operands[0].each.map(zt), $position: i.operands[0].position, $slice: i.operands[0].slice, $sort: i.operands[0].sort } : { $each: i.operands.map(zt) }, n[o][r] = a;
                            break;
                        case je.UNSHIFT:
                            a = { $each: i.operands.map(zt), $position: 0 };
                            n[o][r] = a;
                            break;
                        case je.POP:
                            n[o][r] = 1;
                            break;
                        case je.SHIFT:
                            n[o][r] = -1;
                            break;
                        case je.ADD_TO_SET:
                            n[o][r] = Object(f.g)(i.operands[0]) && i.operands[0].each ? { $each: i.operands[0].each } : i.operands[0];
                            break;
                        case je.PULL:
                            n[o][r] = yo.encode(i.operands[0]);
                            break;
                        case je.PULL_ALL:
                        default:
                            n[o][r] = zt(i.operands[0])
                    }
                } else n.$set || (n.$set = {}), n.$set[r] = zt(i)
            }
            return n
        },
        Ro = function() {
            function e() {}
            return e.encode = function(t) { return (new e).encodeProjection(t) }, e.prototype.encodeProjection = function(e) { return We(e) ? this.encodeProjectionCommand(e) : "object" === Object(f.a)(e) ? this.encodeProjectionObject(e) : e }, e.prototype.encodeProjectionCommand = function(e) {
                var t, n = _o(e.operator);
                switch (e.operator) {
                    case ke.SLICE:
                    default:
                        return (t = {})[n] = e.operands[0], t
                }
            }, e.prototype.encodeProjectionObject = function(e) { var t = kt(e); for (var n in t) !0 === t[n] || 1 === t[n] ? t[n] = 1 : !1 === t[n] || 0 === t[n] ? t[n] = 0 : We(t[n]) ? t[n] = this.encodeProjectionCommand(t[n]) : delete t[n]; return t }, e
        }(),
        Co = function() {
            function e() {}
            return e.decode = function(t) { return (new e).decodeData(t) }, e.prototype.decodeData = function(e) {
                var t = this;
                switch (Object(f.a)(e)) {
                    case "object":
                        return this.decodeObject(e);
                    case "array":
                        return e.map(function(e) { if (Object(f.g)(e)) { var n = Yt(e); return n !== e ? n : t.decodeObject(e) } return e });
                    default:
                        return e
                }
            }, e.prototype.decodeObject = function(e) {
                var t = Object(o.a)({}, e);
                for (var n in t) {
                    var r = t[n];
                    switch (Object(f.a)(r)) {
                        case "object":
                            var i = Yt(r);
                            t[n] = i !== r ? i : this.decodeObject(t[n]);
                            break;
                        case "array":
                            (i = this.decodeData(r)) !== r && (t[n] = i);
                            break;
                        default:
                            continue
                    }
                }
                return t
            }, e
        }();
    ! function(e) { e[e.DEFAULT = 0] = "DEFAULT" }(go || (go = {}));
    var Do = function(e, t) { return new(Lo(e.identifiers || {}))({ context: e, config: t }) };

    function Bo(e) { return e.debug }
    var Lo = function(e) {
        var t, n;
        return function() {
            function o(o) {
                var a = o.config,
                    u = o.context;
                this.identifiers = e, this.config = a || {}, t = { database: this, serviceContext: u, engine: function(e) { return void 0 === e && (e = go.DEFAULT), i }() }, n = uo(t), a && a.env && Object(s.d)(a.env, "string"), this.command = nt, this.Geo = r, this.serverDate = rt, this.RegExp = co, a && a.hasOwnProperty("debug") && Object.defineProperties(this, { debug: { value: !0 }, QuerySerializer: { enumerable: !1, configurable: !1, get: function() { return function(e) { return Bo(e.database) ? e.engine.QuerySerializer : void 0 }(t) }, set: function() {} }, UpdateSerializer: { enumerable: !1, configurable: !1, get: function() { return function(e) { return Bo(e.database) ? e.engine.UpdateSerializer : void 0 }(t) }, set: function() {} }, ProjectionSerializer: { enumerable: !1, configurable: !1, get: function() { return function(e) { return Bo(e.database) ? e.engine.ProjectionSerializer : void 0 }(t) }, set: function() {} }, AggregateSerializer: { enumerable: !1, configurable: !1, get: function() { return function(e) { return Bo(e.database) ? e.engine.AggregateSerializer : void 0 }(t) }, set: function() {} }, Decoder: { enumerable: !1, configurable: !1, get: function() { return function(e) { return Bo(e.database) ? e.engine.Decoder : void 0 }(t) }, set: function() {} } })
            }
            return o.prototype.collection = function(e) { return new n(e) }, o.prototype.toJSON = function() {}, o
        }()
    };
    var jo = "database";

    function Po(e) { var t = { name: jo, identifiers: e.identifiers, request: e.request, isInstance: e.isInstance, get debug() { return e.debug }, get env() { return e.getEnvForService(jo) }, appConfig: {get docSizeLimit() { return e.appConfig.db_doc_size_limit }, get realtimePingInterval() { return e.appConfig.db_realtime_ping_interval }, get realtimePongWaitTimeout() { return e.appConfig.db_realtime_pong_wait_timeout }, get realtimeMaxReconnect() { return e.config.database.realtime.maxReconnect }, get realtimeReconnectInterval() { return e.config.database.realtime.reconnectInterval }, get realtimeTotalConnectionTimeout() { return e.config.database.realtime.totalConnectionTimeout }, get realtimeQueryEventCacheTimeout() { return e.appConfig.db_realtime_query_event_cache_timeout } } }; return { name: jo, context: t, getAPIs: function(e) { return { database: Do.bind(null, e) } }.bind(null, t) } }

    function Mo(e) {
        return {
            CloudID: function(e) {
                var t = function() {
                    function e(e) { this._internalType = m, this.cloudID = e, Object.defineProperties(this, { _internalType: { enumerable: !1, configurable: !1 } }) }
                    return e.prototype.toJSON = function() { return this.cloudID }, e.prototype.toString = function() { return this.cloudID }, e
                }();
                return function(e) { return new t(e) }
            }(),
            CDN: function(e) {
                var t = function() {
                    function e(e) { this._internalType = T, this.target = e, Object.defineProperties(this, { _internalType: { enumerable: !1, configurable: !1 } }) }
                    return e.prototype.toString = function() { return JSON.stringify({ target: this.target }) }, e
                }();
                return function(e) { return new t(e) }
            }()
        }
    }
    var Uo = "utils";

    function xo(e) { e.registerService(function(e) { var t = { name: Uo, identifiers: e.identifiers, request: e.request, isInstance: e.isInstance, get debug() { return e.debug } }; return { name: Uo, context: t, getAPIs: Mo.bind(null, t) } }(e)) }

    function $o(e) {
        ! function(e) { e.registerService(z(e)) }(e),
        function(e) { e.registerService(ae(e)) }(e),
        function(e) { e.registerService(Po(e)) }(e), xo(e),
            function(e) { e.registerService(K(e)) }(e)
    }
    n.d(t, "a", function() { return $o })
}, function(e, t, n) {
    (function(e) {
        var r = void 0 !== e && e || "undefined" != typeof self && self || window,
            i = Function.prototype.apply;

        function o(e, t) { this._id = e, this._clearFn = t }
        t.setTimeout = function() { return new o(i.call(setTimeout, r, arguments), clearTimeout) }, t.setInterval = function() { return new o(i.call(setInterval, r, arguments), clearInterval) }, t.clearTimeout = t.clearInterval = function(e) { e && e.close() }, o.prototype.unref = o.prototype.ref = function() {}, o.prototype.close = function() { this._clearFn.call(r, this._id) }, t.enroll = function(e, t) { clearTimeout(e._idleTimeoutId), e._idleTimeout = t }, t.unenroll = function(e) { clearTimeout(e._idleTimeoutId), e._idleTimeout = -1 }, t._unrefActive = t.active = function(e) {
            clearTimeout(e._idleTimeoutId);
            var t = e._idleTimeout;
            t >= 0 && (e._idleTimeoutId = setTimeout(function() { e._onTimeout && e._onTimeout() }, t))
        }, n(69), t.setImmediate = "undefined" != typeof self && self.setImmediate || void 0 !== e && e.setImmediate || this && this.setImmediate, t.clearImmediate = "undefined" != typeof self && self.clearImmediate || void 0 !== e && e.clearImmediate || this && this.clearImmediate
    }).call(this, n(32))
}, function(e, t, n) {
    (function(e, t) {
        ! function(e, n) {
            "use strict";
            if (!e.setImmediate) {
                var r, i = 1,
                    o = {},
                    a = !1,
                    s = e.document,
                    u = Object.getPrototypeOf && Object.getPrototypeOf(e);
                u = u && u.setTimeout ? u : e, "[object process]" === {}.toString.call(e.process) ? r = function(e) { t.nextTick(function() { f(e) }) } : function() {
                    if (e.postMessage && !e.importScripts) {
                        var t = !0,
                            n = e.onmessage;
                        return e.onmessage = function() { t = !1 }, e.postMessage("", "*"), e.onmessage = n, t
                    }
                }() ? function() {
                    var t = "setImmediate$" + Math.random() + "$",
                        n = function(n) { n.source === e && "string" == typeof n.data && 0 === n.data.indexOf(t) && f(+n.data.slice(t.length)) };
                    e.addEventListener ? e.addEventListener("message", n, !1) : e.attachEvent("onmessage", n), r = function(n) { e.postMessage(t + n, "*") }
                }() : e.MessageChannel ? function() {
                    var e = new MessageChannel;
                    e.port1.onmessage = function(e) { f(e.data) }, r = function(t) { e.port2.postMessage(t) }
                }() : s && "onreadystatechange" in s.createElement("script") ? function() {
                    var e = s.documentElement;
                    r = function(t) {
                        var n = s.createElement("script");
                        n.onreadystatechange = function() { f(t), n.onreadystatechange = null, e.removeChild(n), n = null }, e.appendChild(n)
                    }
                }() : r = function(e) { setTimeout(f, 0, e) }, u.setImmediate = function(e) { "function" != typeof e && (e = new Function("" + e)); for (var t = new Array(arguments.length - 1), n = 0; n < t.length; n++) t[n] = arguments[n + 1]; var a = { callback: e, args: t }; return o[i] = a, r(i), i++ }, u.clearImmediate = c
            }

            function c(e) { delete o[e] }

            function f(e) {
                if (a) setTimeout(f, 0, e);
                else {
                    var t = o[e];
                    if (t) {
                        a = !0;
                        try {
                            ! function(e) {
                                var t = e.callback,
                                    r = e.args;
                                switch (r.length) {
                                    case 0:
                                        t();
                                        break;
                                    case 1:
                                        t(r[0]);
                                        break;
                                    case 2:
                                        t(r[0], r[1]);
                                        break;
                                    case 3:
                                        t(r[0], r[1], r[2]);
                                        break;
                                    default:
                                        t.apply(n, r)
                                }
                            }(t)
                        } finally { c(e), a = !1 }
                    }
                }
            }
        }("undefined" == typeof self ? void 0 === e ? this : e : self)
    }).call(this, n(32), n(61))
}, function(e, t, n) {
    "use strict";
    (function(e) {
        /*!
         * The buffer module from node.js, for the browser.
         *
         * @author   Feross Aboukhadijeh <http://feross.org>
         * @license  MIT
         */
        var r = n(71),
            i = n(72),
            o = n(73);

        function a() { return u.TYPED_ARRAY_SUPPORT ? 2147483647 : 1073741823 }

        function s(e, t) { if (a() < t) throw new RangeError("Invalid typed array length"); return u.TYPED_ARRAY_SUPPORT ? (e = new Uint8Array(t)).__proto__ = u.prototype : (null === e && (e = new u(t)), e.length = t), e }

        function u(e, t, n) { if (!(u.TYPED_ARRAY_SUPPORT || this instanceof u)) return new u(e, t, n); if ("number" == typeof e) { if ("string" == typeof t) throw new Error("If encoding is specified then the first argument must be a string"); return l(this, e) } return c(this, e, t, n) }

        function c(e, t, n, r) {
            if ("number" == typeof t) throw new TypeError('"value" argument must not be a number');
            return "undefined" != typeof ArrayBuffer && t instanceof ArrayBuffer ? function(e, t, n, r) {
                if (t.byteLength, n < 0 || t.byteLength < n) throw new RangeError("'offset' is out of bounds");
                if (t.byteLength < n + (r || 0)) throw new RangeError("'length' is out of bounds");
                t = void 0 === n && void 0 === r ? new Uint8Array(t) : void 0 === r ? new Uint8Array(t, n) : new Uint8Array(t, n, r);
                u.TYPED_ARRAY_SUPPORT ? (e = t).__proto__ = u.prototype : e = d(e, t);
                return e
            }(e, t, n, r) : "string" == typeof t ? function(e, t, n) {
                "string" == typeof n && "" !== n || (n = "utf8");
                if (!u.isEncoding(n)) throw new TypeError('"encoding" must be a valid string encoding');
                var r = 0 | p(t, n),
                    i = (e = s(e, r)).write(t, n);
                i !== r && (e = e.slice(0, i));
                return e
            }(e, t, n) : function(e, t) { if (u.isBuffer(t)) { var n = 0 | h(t.length); return 0 === (e = s(e, n)).length ? e : (t.copy(e, 0, 0, n), e) } if (t) { if ("undefined" != typeof ArrayBuffer && t.buffer instanceof ArrayBuffer || "length" in t) return "number" != typeof t.length || function(e) { return e != e }(t.length) ? s(e, 0) : d(e, t); if ("Buffer" === t.type && o(t.data)) return d(e, t.data) } throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.") }(e, t)
        }

        function f(e) { if ("number" != typeof e) throw new TypeError('"size" argument must be a number'); if (e < 0) throw new RangeError('"size" argument must not be negative') }

        function l(e, t) {
            if (f(t), e = s(e, t < 0 ? 0 : 0 | h(t)), !u.TYPED_ARRAY_SUPPORT)
                for (var n = 0; n < t; ++n) e[n] = 0;
            return e
        }

        function d(e, t) {
            var n = t.length < 0 ? 0 : 0 | h(t.length);
            e = s(e, n);
            for (var r = 0; r < n; r += 1) e[r] = 255 & t[r];
            return e
        }

        function h(e) { if (e >= a()) throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x" + a().toString(16) + " bytes"); return 0 | e }

        function p(e, t) {
            if (u.isBuffer(e)) return e.length;
            if ("undefined" != typeof ArrayBuffer && "function" == typeof ArrayBuffer.isView && (ArrayBuffer.isView(e) || e instanceof ArrayBuffer)) return e.byteLength;
            "string" != typeof e && (e = "" + e);
            var n = e.length;
            if (0 === n) return 0;
            for (var r = !1;;) switch (t) {
                case "ascii":
                case "latin1":
                case "binary":
                    return n;
                case "utf8":
                case "utf-8":
                case void 0:
                    return k(e).length;
                case "ucs2":
                case "ucs-2":
                case "utf16le":
                case "utf-16le":
                    return 2 * n;
                case "hex":
                    return n >>> 1;
                case "base64":
                    return F(e).length;
                default:
                    if (r) return k(e).length;
                    t = ("" + t).toLowerCase(), r = !0
            }
        }

        function _(e, t, n) {
            var r = e[t];
            e[t] = e[n], e[n] = r
        }

        function b(e, t, n, r, i) {
            if (0 === e.length) return -1;
            if ("string" == typeof n ? (r = n, n = 0) : n > 2147483647 ? n = 2147483647 : n < -2147483648 && (n = -2147483648), n = +n, isNaN(n) && (n = i ? 0 : e.length - 1), n < 0 && (n = e.length + n), n >= e.length) {
                if (i) return -1;
                n = e.length - 1
            } else if (n < 0) {
                if (!i) return -1;
                n = 0
            }
            if ("string" == typeof t && (t = u.from(t, r)), u.isBuffer(t)) return 0 === t.length ? -1 : g(e, t, n, r, i);
            if ("number" == typeof t) return t &= 255, u.TYPED_ARRAY_SUPPORT && "function" == typeof Uint8Array.prototype.indexOf ? i ? Uint8Array.prototype.indexOf.call(e, t, n) : Uint8Array.prototype.lastIndexOf.call(e, t, n) : g(e, [t], n, r, i);
            throw new TypeError("val must be string, number or Buffer")
        }

        function g(e, t, n, r, i) {
            var o, a = 1,
                s = e.length,
                u = t.length;
            if (void 0 !== r && ("ucs2" === (r = String(r).toLowerCase()) || "ucs-2" === r || "utf16le" === r || "utf-16le" === r)) {
                if (e.length < 2 || t.length < 2) return -1;
                a = 2, s /= 2, u /= 2, n /= 2
            }

            function c(e, t) { return 1 === a ? e[t] : e.readUInt16BE(t * a) }
            if (i) {
                var f = -1;
                for (o = n; o < s; o++)
                    if (c(e, o) === c(t, -1 === f ? 0 : o - f)) { if (-1 === f && (f = o), o - f + 1 === u) return f * a } else -1 !== f && (o -= o - f), f = -1
            } else
                for (n + u > s && (n = s - u), o = n; o >= 0; o--) {
                    for (var l = !0, d = 0; d < u; d++)
                        if (c(e, o + d) !== c(t, d)) { l = !1; break }
                    if (l) return o
                }
            return -1
        }

        function E(e, t, n, r) {
            n = Number(n) || 0;
            var i = e.length - n;
            r ? (r = Number(r)) > i && (r = i) : r = i;
            var o = t.length;
            if (o % 2 != 0) throw new TypeError("Invalid hex string");
            r > o / 2 && (r = o / 2);
            for (var a = 0; a < r; ++a) {
                var s = parseInt(t.substr(2 * a, 2), 16);
                if (isNaN(s)) return a;
                e[n + a] = s
            }
            return a
        }

        function O(e, t, n, r) { return W(k(t, e.length - n), e, n, r) }

        function y(e, t, n, r) { return W(function(e) { for (var t = [], n = 0; n < e.length; ++n) t.push(255 & e.charCodeAt(n)); return t }(t), e, n, r) }

        function m(e, t, n, r) { return y(e, t, n, r) }

        function T(e, t, n, r) { return W(F(t), e, n, r) }

        function v(e, t, n, r) { return W(function(e, t) { for (var n, r, i, o = [], a = 0; a < e.length && !((t -= 2) < 0); ++a) n = e.charCodeAt(a), r = n >> 8, i = n % 256, o.push(i), o.push(r); return o }(t, e.length - n), e, n, r) }

        function S(e, t, n) { return 0 === t && n === e.length ? r.fromByteArray(e) : r.fromByteArray(e.slice(t, n)) }

        function N(e, t, n) {
            n = Math.min(e.length, n);
            for (var r = [], i = t; i < n;) {
                var o, a, s, u, c = e[i],
                    f = null,
                    l = c > 239 ? 4 : c > 223 ? 3 : c > 191 ? 2 : 1;
                if (i + l <= n) switch (l) {
                    case 1:
                        c < 128 && (f = c);
                        break;
                    case 2:
                        128 == (192 & (o = e[i + 1])) && (u = (31 & c) << 6 | 63 & o) > 127 && (f = u);
                        break;
                    case 3:
                        o = e[i + 1], a = e[i + 2], 128 == (192 & o) && 128 == (192 & a) && (u = (15 & c) << 12 | (63 & o) << 6 | 63 & a) > 2047 && (u < 55296 || u > 57343) && (f = u);
                        break;
                    case 4:
                        o = e[i + 1], a = e[i + 2], s = e[i + 3], 128 == (192 & o) && 128 == (192 & a) && 128 == (192 & s) && (u = (15 & c) << 18 | (63 & o) << 12 | (63 & a) << 6 | 63 & s) > 65535 && u < 1114112 && (f = u)
                }
                null === f ? (f = 65533, l = 1) : f > 65535 && (f -= 65536, r.push(f >>> 10 & 1023 | 55296), f = 56320 | 1023 & f), r.push(f), i += l
            }
            return function(e) {
                var t = e.length;
                if (t <= I) return String.fromCharCode.apply(String, e);
                var n = "",
                    r = 0;
                for (; r < t;) n += String.fromCharCode.apply(String, e.slice(r, r += I));
                return n
            }(r)
        }
        t.Buffer = u, t.SlowBuffer = function(e) {+e != e && (e = 0); return u.alloc(+e) }, t.INSPECT_MAX_BYTES = 50, u.TYPED_ARRAY_SUPPORT = void 0 !== e.TYPED_ARRAY_SUPPORT ? e.TYPED_ARRAY_SUPPORT : function() { try { var e = new Uint8Array(1); return e.__proto__ = { __proto__: Uint8Array.prototype, foo: function() { return 42 } }, 42 === e.foo() && "function" == typeof e.subarray && 0 === e.subarray(1, 1).byteLength } catch (e) { return !1 } }(), t.kMaxLength = a(), u.poolSize = 8192, u._augment = function(e) { return e.__proto__ = u.prototype, e }, u.from = function(e, t, n) { return c(null, e, t, n) }, u.TYPED_ARRAY_SUPPORT && (u.prototype.__proto__ = Uint8Array.prototype, u.__proto__ = Uint8Array, "undefined" != typeof Symbol && Symbol.species && u[Symbol.species] === u && Object.defineProperty(u, Symbol.species, { value: null, configurable: !0 })), u.alloc = function(e, t, n) { return function(e, t, n, r) { return f(t), t <= 0 ? s(e, t) : void 0 !== n ? "string" == typeof r ? s(e, t).fill(n, r) : s(e, t).fill(n) : s(e, t) }(null, e, t, n) }, u.allocUnsafe = function(e) { return l(null, e) }, u.allocUnsafeSlow = function(e) { return l(null, e) }, u.isBuffer = function(e) { return !(null == e || !e._isBuffer) }, u.compare = function(e, t) {
            if (!u.isBuffer(e) || !u.isBuffer(t)) throw new TypeError("Arguments must be Buffers");
            if (e === t) return 0;
            for (var n = e.length, r = t.length, i = 0, o = Math.min(n, r); i < o; ++i)
                if (e[i] !== t[i]) { n = e[i], r = t[i]; break }
            return n < r ? -1 : r < n ? 1 : 0
        }, u.isEncoding = function(e) {
            switch (String(e).toLowerCase()) {
                case "hex":
                case "utf8":
                case "utf-8":
                case "ascii":
                case "latin1":
                case "binary":
                case "base64":
                case "ucs2":
                case "ucs-2":
                case "utf16le":
                case "utf-16le":
                    return !0;
                default:
                    return !1
            }
        }, u.concat = function(e, t) {
            if (!o(e)) throw new TypeError('"list" argument must be an Array of Buffers');
            if (0 === e.length) return u.alloc(0);
            var n;
            if (void 0 === t)
                for (t = 0, n = 0; n < e.length; ++n) t += e[n].length;
            var r = u.allocUnsafe(t),
                i = 0;
            for (n = 0; n < e.length; ++n) {
                var a = e[n];
                if (!u.isBuffer(a)) throw new TypeError('"list" argument must be an Array of Buffers');
                a.copy(r, i), i += a.length
            }
            return r
        }, u.byteLength = p, u.prototype._isBuffer = !0, u.prototype.swap16 = function() { var e = this.length; if (e % 2 != 0) throw new RangeError("Buffer size must be a multiple of 16-bits"); for (var t = 0; t < e; t += 2) _(this, t, t + 1); return this }, u.prototype.swap32 = function() { var e = this.length; if (e % 4 != 0) throw new RangeError("Buffer size must be a multiple of 32-bits"); for (var t = 0; t < e; t += 4) _(this, t, t + 3), _(this, t + 1, t + 2); return this }, u.prototype.swap64 = function() { var e = this.length; if (e % 8 != 0) throw new RangeError("Buffer size must be a multiple of 64-bits"); for (var t = 0; t < e; t += 8) _(this, t, t + 7), _(this, t + 1, t + 6), _(this, t + 2, t + 5), _(this, t + 3, t + 4); return this }, u.prototype.toString = function() {
            var e = 0 | this.length;
            return 0 === e ? "" : 0 === arguments.length ? N(this, 0, e) : function(e, t, n) {
                var r = !1;
                if ((void 0 === t || t < 0) && (t = 0), t > this.length) return "";
                if ((void 0 === n || n > this.length) && (n = this.length), n <= 0) return "";
                if ((n >>>= 0) <= (t >>>= 0)) return "";
                for (e || (e = "utf8");;) switch (e) {
                    case "hex":
                        return R(this, t, n);
                    case "utf8":
                    case "utf-8":
                        return N(this, t, n);
                    case "ascii":
                        return A(this, t, n);
                    case "latin1":
                    case "binary":
                        return w(this, t, n);
                    case "base64":
                        return S(this, t, n);
                    case "ucs2":
                    case "ucs-2":
                    case "utf16le":
                    case "utf-16le":
                        return C(this, t, n);
                    default:
                        if (r) throw new TypeError("Unknown encoding: " + e);
                        e = (e + "").toLowerCase(), r = !0
                }
            }.apply(this, arguments)
        }, u.prototype.equals = function(e) { if (!u.isBuffer(e)) throw new TypeError("Argument must be a Buffer"); return this === e || 0 === u.compare(this, e) }, u.prototype.inspect = function() {
            var e = "",
                n = t.INSPECT_MAX_BYTES;
            return this.length > 0 && (e = this.toString("hex", 0, n).match(/.{2}/g).join(" "), this.length > n && (e += " ... ")), "<Buffer " + e + ">"
        }, u.prototype.compare = function(e, t, n, r, i) {
            if (!u.isBuffer(e)) throw new TypeError("Argument must be a Buffer");
            if (void 0 === t && (t = 0), void 0 === n && (n = e ? e.length : 0), void 0 === r && (r = 0), void 0 === i && (i = this.length), t < 0 || n > e.length || r < 0 || i > this.length) throw new RangeError("out of range index");
            if (r >= i && t >= n) return 0;
            if (r >= i) return -1;
            if (t >= n) return 1;
            if (t >>>= 0, n >>>= 0, r >>>= 0, i >>>= 0, this === e) return 0;
            for (var o = i - r, a = n - t, s = Math.min(o, a), c = this.slice(r, i), f = e.slice(t, n), l = 0; l < s; ++l)
                if (c[l] !== f[l]) { o = c[l], a = f[l]; break }
            return o < a ? -1 : a < o ? 1 : 0
        }, u.prototype.includes = function(e, t, n) { return -1 !== this.indexOf(e, t, n) }, u.prototype.indexOf = function(e, t, n) { return b(this, e, t, n, !0) }, u.prototype.lastIndexOf = function(e, t, n) { return b(this, e, t, n, !1) }, u.prototype.write = function(e, t, n, r) {
            if (void 0 === t) r = "utf8", n = this.length, t = 0;
            else if (void 0 === n && "string" == typeof t) r = t, n = this.length, t = 0;
            else {
                if (!isFinite(t)) throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");
                t |= 0, isFinite(n) ? (n |= 0, void 0 === r && (r = "utf8")) : (r = n, n = void 0)
            }
            var i = this.length - t;
            if ((void 0 === n || n > i) && (n = i), e.length > 0 && (n < 0 || t < 0) || t > this.length) throw new RangeError("Attempt to write outside buffer bounds");
            r || (r = "utf8");
            for (var o = !1;;) switch (r) {
                case "hex":
                    return E(this, e, t, n);
                case "utf8":
                case "utf-8":
                    return O(this, e, t, n);
                case "ascii":
                    return y(this, e, t, n);
                case "latin1":
                case "binary":
                    return m(this, e, t, n);
                case "base64":
                    return T(this, e, t, n);
                case "ucs2":
                case "ucs-2":
                case "utf16le":
                case "utf-16le":
                    return v(this, e, t, n);
                default:
                    if (o) throw new TypeError("Unknown encoding: " + r);
                    r = ("" + r).toLowerCase(), o = !0
            }
        }, u.prototype.toJSON = function() { return { type: "Buffer", data: Array.prototype.slice.call(this._arr || this, 0) } };
        var I = 4096;

        function A(e, t, n) {
            var r = "";
            n = Math.min(e.length, n);
            for (var i = t; i < n; ++i) r += String.fromCharCode(127 & e[i]);
            return r
        }

        function w(e, t, n) {
            var r = "";
            n = Math.min(e.length, n);
            for (var i = t; i < n; ++i) r += String.fromCharCode(e[i]);
            return r
        }

        function R(e, t, n) {
            var r = e.length;
            (!t || t < 0) && (t = 0), (!n || n < 0 || n > r) && (n = r);
            for (var i = "", o = t; o < n; ++o) i += $(e[o]);
            return i
        }

        function C(e, t, n) { for (var r = e.slice(t, n), i = "", o = 0; o < r.length; o += 2) i += String.fromCharCode(r[o] + 256 * r[o + 1]); return i }

        function D(e, t, n) { if (e % 1 != 0 || e < 0) throw new RangeError("offset is not uint"); if (e + t > n) throw new RangeError("Trying to access beyond buffer length") }

        function B(e, t, n, r, i, o) { if (!u.isBuffer(e)) throw new TypeError('"buffer" argument must be a Buffer instance'); if (t > i || t < o) throw new RangeError('"value" argument is out of bounds'); if (n + r > e.length) throw new RangeError("Index out of range") }

        function L(e, t, n, r) { t < 0 && (t = 65535 + t + 1); for (var i = 0, o = Math.min(e.length - n, 2); i < o; ++i) e[n + i] = (t & 255 << 8 * (r ? i : 1 - i)) >>> 8 * (r ? i : 1 - i) }

        function j(e, t, n, r) { t < 0 && (t = 4294967295 + t + 1); for (var i = 0, o = Math.min(e.length - n, 4); i < o; ++i) e[n + i] = t >>> 8 * (r ? i : 3 - i) & 255 }

        function P(e, t, n, r, i, o) { if (n + r > e.length) throw new RangeError("Index out of range"); if (n < 0) throw new RangeError("Index out of range") }

        function M(e, t, n, r, o) { return o || P(e, 0, n, 4), i.write(e, t, n, r, 23, 4), n + 4 }

        function U(e, t, n, r, o) { return o || P(e, 0, n, 8), i.write(e, t, n, r, 52, 8), n + 8 }
        u.prototype.slice = function(e, t) {
            var n, r = this.length;
            if (e = ~~e, t = void 0 === t ? r : ~~t, e < 0 ? (e += r) < 0 && (e = 0) : e > r && (e = r), t < 0 ? (t += r) < 0 && (t = 0) : t > r && (t = r), t < e && (t = e), u.TYPED_ARRAY_SUPPORT)(n = this.subarray(e, t)).__proto__ = u.prototype;
            else {
                var i = t - e;
                n = new u(i, void 0);
                for (var o = 0; o < i; ++o) n[o] = this[o + e]
            }
            return n
        }, u.prototype.readUIntLE = function(e, t, n) { e |= 0, t |= 0, n || D(e, t, this.length); for (var r = this[e], i = 1, o = 0; ++o < t && (i *= 256);) r += this[e + o] * i; return r }, u.prototype.readUIntBE = function(e, t, n) { e |= 0, t |= 0, n || D(e, t, this.length); for (var r = this[e + --t], i = 1; t > 0 && (i *= 256);) r += this[e + --t] * i; return r }, u.prototype.readUInt8 = function(e, t) { return t || D(e, 1, this.length), this[e] }, u.prototype.readUInt16LE = function(e, t) { return t || D(e, 2, this.length), this[e] | this[e + 1] << 8 }, u.prototype.readUInt16BE = function(e, t) { return t || D(e, 2, this.length), this[e] << 8 | this[e + 1] }, u.prototype.readUInt32LE = function(e, t) { return t || D(e, 4, this.length), (this[e] | this[e + 1] << 8 | this[e + 2] << 16) + 16777216 * this[e + 3] }, u.prototype.readUInt32BE = function(e, t) { return t || D(e, 4, this.length), 16777216 * this[e] + (this[e + 1] << 16 | this[e + 2] << 8 | this[e + 3]) }, u.prototype.readIntLE = function(e, t, n) { e |= 0, t |= 0, n || D(e, t, this.length); for (var r = this[e], i = 1, o = 0; ++o < t && (i *= 256);) r += this[e + o] * i; return r >= (i *= 128) && (r -= Math.pow(2, 8 * t)), r }, u.prototype.readIntBE = function(e, t, n) { e |= 0, t |= 0, n || D(e, t, this.length); for (var r = t, i = 1, o = this[e + --r]; r > 0 && (i *= 256);) o += this[e + --r] * i; return o >= (i *= 128) && (o -= Math.pow(2, 8 * t)), o }, u.prototype.readInt8 = function(e, t) { return t || D(e, 1, this.length), 128 & this[e] ? -1 * (255 - this[e] + 1) : this[e] }, u.prototype.readInt16LE = function(e, t) { t || D(e, 2, this.length); var n = this[e] | this[e + 1] << 8; return 32768 & n ? 4294901760 | n : n }, u.prototype.readInt16BE = function(e, t) { t || D(e, 2, this.length); var n = this[e + 1] | this[e] << 8; return 32768 & n ? 4294901760 | n : n }, u.prototype.readInt32LE = function(e, t) { return t || D(e, 4, this.length), this[e] | this[e + 1] << 8 | this[e + 2] << 16 | this[e + 3] << 24 }, u.prototype.readInt32BE = function(e, t) { return t || D(e, 4, this.length), this[e] << 24 | this[e + 1] << 16 | this[e + 2] << 8 | this[e + 3] }, u.prototype.readFloatLE = function(e, t) { return t || D(e, 4, this.length), i.read(this, e, !0, 23, 4) }, u.prototype.readFloatBE = function(e, t) { return t || D(e, 4, this.length), i.read(this, e, !1, 23, 4) }, u.prototype.readDoubleLE = function(e, t) { return t || D(e, 8, this.length), i.read(this, e, !0, 52, 8) }, u.prototype.readDoubleBE = function(e, t) { return t || D(e, 8, this.length), i.read(this, e, !1, 52, 8) }, u.prototype.writeUIntLE = function(e, t, n, r) {
            (e = +e, t |= 0, n |= 0, r) || B(this, e, t, n, Math.pow(2, 8 * n) - 1, 0);
            var i = 1,
                o = 0;
            for (this[t] = 255 & e; ++o < n && (i *= 256);) this[t + o] = e / i & 255;
            return t + n
        }, u.prototype.writeUIntBE = function(e, t, n, r) {
            (e = +e, t |= 0, n |= 0, r) || B(this, e, t, n, Math.pow(2, 8 * n) - 1, 0);
            var i = n - 1,
                o = 1;
            for (this[t + i] = 255 & e; --i >= 0 && (o *= 256);) this[t + i] = e / o & 255;
            return t + n
        }, u.prototype.writeUInt8 = function(e, t, n) { return e = +e, t |= 0, n || B(this, e, t, 1, 255, 0), u.TYPED_ARRAY_SUPPORT || (e = Math.floor(e)), this[t] = 255 & e, t + 1 }, u.prototype.writeUInt16LE = function(e, t, n) { return e = +e, t |= 0, n || B(this, e, t, 2, 65535, 0), u.TYPED_ARRAY_SUPPORT ? (this[t] = 255 & e, this[t + 1] = e >>> 8) : L(this, e, t, !0), t + 2 }, u.prototype.writeUInt16BE = function(e, t, n) { return e = +e, t |= 0, n || B(this, e, t, 2, 65535, 0), u.TYPED_ARRAY_SUPPORT ? (this[t] = e >>> 8, this[t + 1] = 255 & e) : L(this, e, t, !1), t + 2 }, u.prototype.writeUInt32LE = function(e, t, n) { return e = +e, t |= 0, n || B(this, e, t, 4, 4294967295, 0), u.TYPED_ARRAY_SUPPORT ? (this[t + 3] = e >>> 24, this[t + 2] = e >>> 16, this[t + 1] = e >>> 8, this[t] = 255 & e) : j(this, e, t, !0), t + 4 }, u.prototype.writeUInt32BE = function(e, t, n) { return e = +e, t |= 0, n || B(this, e, t, 4, 4294967295, 0), u.TYPED_ARRAY_SUPPORT ? (this[t] = e >>> 24, this[t + 1] = e >>> 16, this[t + 2] = e >>> 8, this[t + 3] = 255 & e) : j(this, e, t, !1), t + 4 }, u.prototype.writeIntLE = function(e, t, n, r) {
            if (e = +e, t |= 0, !r) {
                var i = Math.pow(2, 8 * n - 1);
                B(this, e, t, n, i - 1, -i)
            }
            var o = 0,
                a = 1,
                s = 0;
            for (this[t] = 255 & e; ++o < n && (a *= 256);) e < 0 && 0 === s && 0 !== this[t + o - 1] && (s = 1), this[t + o] = (e / a >> 0) - s & 255;
            return t + n
        }, u.prototype.writeIntBE = function(e, t, n, r) {
            if (e = +e, t |= 0, !r) {
                var i = Math.pow(2, 8 * n - 1);
                B(this, e, t, n, i - 1, -i)
            }
            var o = n - 1,
                a = 1,
                s = 0;
            for (this[t + o] = 255 & e; --o >= 0 && (a *= 256);) e < 0 && 0 === s && 0 !== this[t + o + 1] && (s = 1), this[t + o] = (e / a >> 0) - s & 255;
            return t + n
        }, u.prototype.writeInt8 = function(e, t, n) { return e = +e, t |= 0, n || B(this, e, t, 1, 127, -128), u.TYPED_ARRAY_SUPPORT || (e = Math.floor(e)), e < 0 && (e = 255 + e + 1), this[t] = 255 & e, t + 1 }, u.prototype.writeInt16LE = function(e, t, n) { return e = +e, t |= 0, n || B(this, e, t, 2, 32767, -32768), u.TYPED_ARRAY_SUPPORT ? (this[t] = 255 & e, this[t + 1] = e >>> 8) : L(this, e, t, !0), t + 2 }, u.prototype.writeInt16BE = function(e, t, n) { return e = +e, t |= 0, n || B(this, e, t, 2, 32767, -32768), u.TYPED_ARRAY_SUPPORT ? (this[t] = e >>> 8, this[t + 1] = 255 & e) : L(this, e, t, !1), t + 2 }, u.prototype.writeInt32LE = function(e, t, n) { return e = +e, t |= 0, n || B(this, e, t, 4, 2147483647, -2147483648), u.TYPED_ARRAY_SUPPORT ? (this[t] = 255 & e, this[t + 1] = e >>> 8, this[t + 2] = e >>> 16, this[t + 3] = e >>> 24) : j(this, e, t, !0), t + 4 }, u.prototype.writeInt32BE = function(e, t, n) { return e = +e, t |= 0, n || B(this, e, t, 4, 2147483647, -2147483648), e < 0 && (e = 4294967295 + e + 1), u.TYPED_ARRAY_SUPPORT ? (this[t] = e >>> 24, this[t + 1] = e >>> 16, this[t + 2] = e >>> 8, this[t + 3] = 255 & e) : j(this, e, t, !1), t + 4 }, u.prototype.writeFloatLE = function(e, t, n) { return M(this, e, t, !0, n) }, u.prototype.writeFloatBE = function(e, t, n) { return M(this, e, t, !1, n) }, u.prototype.writeDoubleLE = function(e, t, n) { return U(this, e, t, !0, n) }, u.prototype.writeDoubleBE = function(e, t, n) { return U(this, e, t, !1, n) }, u.prototype.copy = function(e, t, n, r) {
            if (n || (n = 0), r || 0 === r || (r = this.length), t >= e.length && (t = e.length), t || (t = 0), r > 0 && r < n && (r = n), r === n) return 0;
            if (0 === e.length || 0 === this.length) return 0;
            if (t < 0) throw new RangeError("targetStart out of bounds");
            if (n < 0 || n >= this.length) throw new RangeError("sourceStart out of bounds");
            if (r < 0) throw new RangeError("sourceEnd out of bounds");
            r > this.length && (r = this.length), e.length - t < r - n && (r = e.length - t + n);
            var i, o = r - n;
            if (this === e && n < t && t < r)
                for (i = o - 1; i >= 0; --i) e[i + t] = this[i + n];
            else if (o < 1e3 || !u.TYPED_ARRAY_SUPPORT)
                for (i = 0; i < o; ++i) e[i + t] = this[i + n];
            else Uint8Array.prototype.set.call(e, this.subarray(n, n + o), t);
            return o
        }, u.prototype.fill = function(e, t, n, r) {
            if ("string" == typeof e) {
                if ("string" == typeof t ? (r = t, t = 0, n = this.length) : "string" == typeof n && (r = n, n = this.length), 1 === e.length) {
                    var i = e.charCodeAt(0);
                    i < 256 && (e = i)
                }
                if (void 0 !== r && "string" != typeof r) throw new TypeError("encoding must be a string");
                if ("string" == typeof r && !u.isEncoding(r)) throw new TypeError("Unknown encoding: " + r)
            } else "number" == typeof e && (e &= 255);
            if (t < 0 || this.length < t || this.length < n) throw new RangeError("Out of range index");
            if (n <= t) return this;
            var o;
            if (t >>>= 0, n = void 0 === n ? this.length : n >>> 0, e || (e = 0), "number" == typeof e)
                for (o = t; o < n; ++o) this[o] = e;
            else {
                var a = u.isBuffer(e) ? e : k(new u(e, r).toString()),
                    s = a.length;
                for (o = 0; o < n - t; ++o) this[o + t] = a[o % s]
            }
            return this
        };
        var x = /[^+\/0-9A-Za-z-_]/g;

        function $(e) { return e < 16 ? "0" + e.toString(16) : e.toString(16) }

        function k(e, t) {
            var n;
            t = t || 1 / 0;
            for (var r = e.length, i = null, o = [], a = 0; a < r; ++a) {
                if ((n = e.charCodeAt(a)) > 55295 && n < 57344) {
                    if (!i) {
                        if (n > 56319) {
                            (t -= 3) > -1 && o.push(239, 191, 189);
                            continue
                        }
                        if (a + 1 === r) {
                            (t -= 3) > -1 && o.push(239, 191, 189);
                            continue
                        }
                        i = n;
                        continue
                    }
                    if (n < 56320) {
                        (t -= 3) > -1 && o.push(239, 191, 189), i = n;
                        continue
                    }
                    n = 65536 + (i - 55296 << 10 | n - 56320)
                } else i && (t -= 3) > -1 && o.push(239, 191, 189);
                if (i = null, n < 128) {
                    if ((t -= 1) < 0) break;
                    o.push(n)
                } else if (n < 2048) {
                    if ((t -= 2) < 0) break;
                    o.push(n >> 6 | 192, 63 & n | 128)
                } else if (n < 65536) {
                    if ((t -= 3) < 0) break;
                    o.push(n >> 12 | 224, n >> 6 & 63 | 128, 63 & n | 128)
                } else {
                    if (!(n < 1114112)) throw new Error("Invalid code point");
                    if ((t -= 4) < 0) break;
                    o.push(n >> 18 | 240, n >> 12 & 63 | 128, n >> 6 & 63 | 128, 63 & n | 128)
                }
            }
            return o
        }

        function F(e) { return r.toByteArray(function(e) { if ((e = function(e) { return e.trim ? e.trim() : e.replace(/^\s+|\s+$/g, "") }(e).replace(x, "")).length < 2) return ""; for (; e.length % 4 != 0;) e += "="; return e }(e)) }

        function W(e, t, n, r) { for (var i = 0; i < r && !(i + n >= t.length || i >= e.length); ++i) t[i + n] = e[i]; return i }
    }).call(this, n(32))
}, function(e, t, n) {
    "use strict";
    t.byteLength = function(e) {
        var t = c(e),
            n = t[0],
            r = t[1];
        return 3 * (n + r) / 4 - r
    }, t.toByteArray = function(e) {
        var t, n, r = c(e),
            a = r[0],
            s = r[1],
            u = new o(function(e, t, n) { return 3 * (t + n) / 4 - n }(0, a, s)),
            f = 0,
            l = s > 0 ? a - 4 : a;
        for (n = 0; n < l; n += 4) t = i[e.charCodeAt(n)] << 18 | i[e.charCodeAt(n + 1)] << 12 | i[e.charCodeAt(n + 2)] << 6 | i[e.charCodeAt(n + 3)], u[f++] = t >> 16 & 255, u[f++] = t >> 8 & 255, u[f++] = 255 & t;
        2 === s && (t = i[e.charCodeAt(n)] << 2 | i[e.charCodeAt(n + 1)] >> 4, u[f++] = 255 & t);
        1 === s && (t = i[e.charCodeAt(n)] << 10 | i[e.charCodeAt(n + 1)] << 4 | i[e.charCodeAt(n + 2)] >> 2, u[f++] = t >> 8 & 255, u[f++] = 255 & t);
        return u
    }, t.fromByteArray = function(e) {
        for (var t, n = e.length, i = n % 3, o = [], a = 0, s = n - i; a < s; a += 16383) o.push(l(e, a, a + 16383 > s ? s : a + 16383));
        1 === i ? (t = e[n - 1], o.push(r[t >> 2] + r[t << 4 & 63] + "==")) : 2 === i && (t = (e[n - 2] << 8) + e[n - 1], o.push(r[t >> 10] + r[t >> 4 & 63] + r[t << 2 & 63] + "="));
        return o.join("")
    };
    for (var r = [], i = [], o = "undefined" != typeof Uint8Array ? Uint8Array : Array, a = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", s = 0, u = a.length; s < u; ++s) r[s] = a[s], i[a.charCodeAt(s)] = s;

    function c(e) { var t = e.length; if (t % 4 > 0) throw new Error("Invalid string. Length must be a multiple of 4"); var n = e.indexOf("="); return -1 === n && (n = t), [n, n === t ? 0 : 4 - n % 4] }

    function f(e) { return r[e >> 18 & 63] + r[e >> 12 & 63] + r[e >> 6 & 63] + r[63 & e] }

    function l(e, t, n) { for (var r, i = [], o = t; o < n; o += 3) r = (e[o] << 16 & 16711680) + (e[o + 1] << 8 & 65280) + (255 & e[o + 2]), i.push(f(r)); return i.join("") }
    i["-".charCodeAt(0)] = 62, i["_".charCodeAt(0)] = 63
}, function(e, t) {
    t.read = function(e, t, n, r, i) {
        var o, a, s = 8 * i - r - 1,
            u = (1 << s) - 1,
            c = u >> 1,
            f = -7,
            l = n ? i - 1 : 0,
            d = n ? -1 : 1,
            h = e[t + l];
        for (l += d, o = h & (1 << -f) - 1, h >>= -f, f += s; f > 0; o = 256 * o + e[t + l], l += d, f -= 8);
        for (a = o & (1 << -f) - 1, o >>= -f, f += r; f > 0; a = 256 * a + e[t + l], l += d, f -= 8);
        if (0 === o) o = 1 - c;
        else {
            if (o === u) return a ? NaN : 1 / 0 * (h ? -1 : 1);
            a += Math.pow(2, r), o -= c
        }
        return (h ? -1 : 1) * a * Math.pow(2, o - r)
    }, t.write = function(e, t, n, r, i, o) {
        var a, s, u, c = 8 * o - i - 1,
            f = (1 << c) - 1,
            l = f >> 1,
            d = 23 === i ? Math.pow(2, -24) - Math.pow(2, -77) : 0,
            h = r ? 0 : o - 1,
            p = r ? 1 : -1,
            _ = t < 0 || 0 === t && 1 / t < 0 ? 1 : 0;
        for (t = Math.abs(t), isNaN(t) || t === 1 / 0 ? (s = isNaN(t) ? 1 : 0, a = f) : (a = Math.floor(Math.log(t) / Math.LN2), t * (u = Math.pow(2, -a)) < 1 && (a--, u *= 2), (t += a + l >= 1 ? d / u : d * Math.pow(2, 1 - l)) * u >= 2 && (a++, u /= 2), a + l >= f ? (s = 0, a = f) : a + l >= 1 ? (s = (t * u - 1) * Math.pow(2, i), a += l) : (s = t * Math.pow(2, l - 1) * Math.pow(2, i), a = 0)); i >= 8; e[n + h] = 255 & s, h += p, s /= 256, i -= 8);
        for (a = a << i | s, c += i; c > 0; e[n + h] = 255 & a, h += p, a /= 256, c -= 8);
        e[n + h - p] |= 128 * _
    }
}, function(e, t) {
    var n = {}.toString;
    e.exports = Array.isArray || function(e) { return "[object Array]" == n.call(e) }
}, function(e, t, n) {
    "use strict";
    n.r(t);
    var r, i, o = n(64);
    n(0), n(9), n(6);
    ! function(e) { e[e.CALL = 1] = "CALL", e[e.POLL = 2] = "POLL", e[e.PreResp = 3] = "PreResp", e[e.FinalResp = 4] = "FinalResp" }(r || (r = {})),
    function(e) { e[e.None = 0] = "None", e[e.SysErr = 1] = "SysErr", e[e.Timeout = 2] = "Timeout" }(i || (i = {}));
    n(13), n(1), n(8);
    var a = Symbol("CDN");
    var s = n(50),
        u = Object(o.a)();
    u.registerService(Object(s.a)(u)), u.exportAPI.version = { updateTime: "2020.10.12 12:11:43", version: "1.1.0" }, "undefined" != typeof wx && (wx.cloud = u.exportAPI), window.cloud = u.exportAPI
}]));